note 54132 added to functions.arguments

From: Date: Fri, 24 Jun 2005 14:21:49 +0000
Subject: note 54132 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-90898@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54132 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54132&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54132&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90898) next »