<?php
class A {
var $foo = 1;
}
function update($obj) {
$obj->foo = 3;
}
function replace($obj) {
$a = new A;
$a->foo = 3;
$obj = $a;
}
function replaceByRef(&$obj) {
$a = new A;
$a->foo = 3;
$obj = $a;
}
$a = new A; $b = new A; $c = new A;
call_user_func_array("update", array(&$a));
call_user_func_array("replace", array(&$b));
call_user_func_array("replaceByRef", array(&$c));
echo $a->foo . "\n";
echo $b->foo . "\n";
echo $c->foo . "\n";
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.24, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- 3
1
3
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- 3
3
3
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
- Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/3g5cb on line 3
3
3
3
preferences:
84.43 ms | 408 KiB | 5 Q