ID:               35487
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kenashkov at gmail dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Fedora Core 4
 PHP Version:      Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"Whether to warn when arguments are passed by reference at function
call time."

"the argument will be passed by value instead of by reference" removed.


Previous Comments:
------------------------------------------------------------------------

[2005-11-30 13:40:52] kenashkov at gmail dot com

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 this bug report at http://bugs.php.net/?id=35487&edit=1

Reply via email to