严格标准:只有变量才能通过引用传递。$el = array_shift($instance->find(..))上面的代码以某种方式报告了严格的标准警告,但这不会:function get_arr(){
return array(1,2);}$el = array_shift(get_arr());那么,它什么时候会报告警告呢?
4 回答

斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
error_reporting(E_STRICT);class test { function test_arr(&$a) { var_dump($a); } function get_arr() { return array(1,2); }}$t= new test;$t->test_arr($t->get_arr());
Strict Standards: Only variables should be passed by reference in `test.php` on line 14array(2) { [0]=> int(1) [1]=> int(2)}
test::get_arr()
get_arr()
function test_arr($a) { var_dump($a); }
array_shift
$inter= get_arr();$el= array_shift($inter);

慕工程0101907
TA贡献1887条经验 获得超5个赞
$instance->find()
function &get_arr(){ return array(1,2);}$el = array_shift(get_arr());
$el = array_shift($tmp = $instance->find(..));

慕桂英4014372
TA贡献1871条经验 获得超13个赞
array_shift
- 4 回答
- 0 关注
- 537 浏览
添加回答
举报
0/150
提交
取消