PHP 8.5.0 Beta 1 available for testing

Voting

: min(eight, eight)?
(Example: nine)

The Note You're Voting On

donny at semeleer dot nl
19 years ago
Here's an example of unsetting a reference without losing an ealier set reference

<?php
$foo
= 'Bob'; // Assign the value 'Bob' to $foo
$bar = &$foo; // Reference $foo via $bar.
$bar = "My name is $bar"; // Alter $bar...
echo $bar;
echo
$foo; // $foo is altered too.
$foo = "I am Frank"; // Alter $foo and $bar because of the reference
echo $bar; // output: I am Frank
echo $foo; // output: I am Frank

$foobar = &$bar; // create a new reference between $foobar and $bar
$foobar = "hello $foobar"; // alter $foobar and with that $bar and $foo
echo $foobar; //output : hello I am Frank
unset($bar); // unset $bar and destroy the reference
$bar = "dude!"; // assign $bar
/* even though the reference between $bar and $foo is destroyed, and also the
reference between $bar and $foobar is destroyed, there is still a reference
between $foo and $foobar. */
echo $foo; // output : hello I am Frank
echo $bar; // output : due!
?>

<< Back to user notes page

To Top