From: kenashkov at gmail dot com Operating system: Fedora Core 4 PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: allow_call_time_pass_reference - Actually is still possible to pass argument by
Description: ------------ Quote from the docs about the php.ini directive "allow_call_time_pass_reference": "Whether to enable the ability to force arguments to be passed by reference at function call time. ... " According to the docs in the second case (=Off) it must warn and _pass by value_. But in both cases (=On =Off) the argument is passed by reference. Wheter the docs are incorrect - it should stand something like: " Whether to warn when arguments are passed by reference at function call time. ..." or it is an internal PHP problem. In my opinion the call time pass reference is still useful in two cases: 1) serializing recursive arrays: <? $arr1[0] =& $arr1; print_r(unserialize(serialize($arr1))); ?> expected: Array ( [0] => Array *RECURSION* ) actual: Array ( [0] => Array ( [0] => ) ) This can be solved using: print_r(unserialize(serialize(&$arr1))) , which is deprecated, or print_r(unserialize(serialize($ref=&$arr1))), which returns almost as expected: Array ( [0] => Array ( [0] => Array *RECURSION* ) ) In fact it is the same, although PHP does show the recursion one level deeper. 2) When counting the references to an object. The following code prints the cound of the clones of the object: <? class test{} $obj1 = new test(); $obj2 = $obj1; debug_zval_dump($obj1);//object(test)(0) refcount(3){ } ?> And to count the references to the object we must use: <? class test{} $obj1 = new test(); $ref1 =& $obj1; debug_zval_dump(&$obj1);//object(test)(0) refcount(3){ } ?> Reproduce code: --------------- <? /* allow_call_time_pass_reference=Off; */ function test($arg1) { $arg1 = 55; } $var1 = 44; test(&$var1); print $var1; ?> Expected result: ---------------- 44 Actual result: -------------- 55 /* + PHP warning ... */ -- Edit bug report at http://bugs.php.net/?id=35487&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35487&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35487&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35487&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=35487&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35487&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35487&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35487&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35487&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35487&r=support Expected behavior: http://bugs.php.net/fix.php?id=35487&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35487&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35487&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35487&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35487&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35487&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35487&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35487&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35487&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35487&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35487&r=mysqlcfg