update page now

Voting

: one plus eight?
(Example: nine)

The Note You're Voting On

minhtrung2606 at gmail dot com
6 years ago
<?php
function foo(&$var)
{
    $var =& $GLOBALS["baz"];
}
foo($bar); 
?>

Let's re-write the above snippet of code in another way

<?php
$bar = &$var; // At this time, $bar refers to the content to which $var refers which is NULL or empty
$var = & $GLOBALS["baz"]; // At this time, $var changes to refer to another content to which global $baz variable refers. However $bar is still refers to the content of NULL

Expected Result: $bar will hold the content of $var (which is now the content of $baz)
Actual Result: $bar holds a content of NULL or empty. This is what's PHP References does

<< Back to user notes page

To Top