我有一些代码:
测试控制器:
Class test extends CI_Controller{
public function print_object(){
$x = (object) array('a'=>'A', 'b'=>'B', 'C');
echo '<pre>'.print_r($x, true).'</pre>';
}
}
测试2控制器:
Class test2 extends CI_Controller{
public function get_printed_object(){
$url = "http://localhost/project/test/print_object";
(object) $str = file_get_contents($url);
echo $str->a; //won't make it. resulting error
}
}
线
echo $str->a;
结果是警告:尝试获取非对象的属性
我可以重新制作打印到字符串的 $x 对象吗?