注意:在回显数组时将数组转换为字符串 [英] Notice: Array to string conversion when echoing the array

查看:63
本文介绍了注意:在回显数组时将数组转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM收到错误

Notice: Array to string conversion php

通过从外部类中调用我的数组..任何人都可以在这里发现问题

by calling my array from a outside class.. can anybody spot the problem here

脚本主页.php

echo b::addarray(123, sea, 1);//i tried this way,dint work either("123","sea","1")
die();

具有数组的脚本

class b
{

    static function addarray($a,$b,$c){

        $red = array();
        array_push($red, $a,$b,$c);
        return $red;
    }
}


推荐答案

尝试如下所示,当您回显数组时,您需要使用 print_r() var_dump()

Try it as follows, as you were echoing an array you need to use print_r() or var_dump()

$re = new b();
$result = $re::addarray(123,'sea',1);
print_r($result);

这篇关于注意:在回显数组时将数组转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆