note 54132 deleted from functions.arguments by nikic
| From: | nikic@php.net | Date: | Wed, 30 Apr 2014 15:38:17 +0000 |
| Subject: | note 54132 deleted from functions.arguments by nikic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-199387@lists.php.net to get a copy of this message | ||
Note Submitter: benk at NOSPAM dot icarz dot com
----
This isn't necessarily the right place to store this piece of information, but I discovered a
neat feature of the 'by reference' operator (&). You can use this assignment operator
to assign a pointer to another variable. This makes it possible to update BOTH varaibles and have
the value change in the other. I have not yet explored scope of this test, but here is a simple
test that I ran on PHP 4.3.9 with the following results:
$abc = "Test";
$def = "";
print("ABC = $abc\tDEF = $def\n"); // ABC = Test DEF =
$def = &$abc;
print("ABC = $abc\tDEF = $def\n"); // ABC = Test DEF = Test
$abc = "test2";
print("ABC = $abc\tDEF = $def\n"); // ABC = test2 DEF = test2
$def = "nextval";
print("ABC = $abc\tDEF = $def\n"); // ABC = nextval DEF = nextval
unset($def);
print("ABC = $abc\tDEF = $def\n"); // ABC = nextval DEF =
$def = "yet another value";
print("ABC = $abc\tDEF = $def\n"); // ABC = nextval DEF = yet another value