note 71170 added to language.references.arent
| From: | TomekPerlak | Date: | Tue, 14 Nov 2006 18:33:42 +0000 |
| Subject: | note 71170 added to language.references.arent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119729@lists.php.net to get a copy of this message | ||
I needed a function to set a few globals for me. The globals had very long names (to be somewhat
unique), so the function started to look really ugly.
Using a reference helped me to clean up the code a little.
Here's an interesing way of using references with globals - in a bit of a
'pointer-like' way.
<?
function f1()
{
global $g_B, $g_C;
$v =& $g_B;
$v = 91;
$v =& $NULL;
$v =& $g_C;
$v = 45;
$v =& $NULL;
}
f1();
echo $g_B . ", " . $g_C;
?>
The result is:
91, 45
Btw, does it really matter how much the references are like or unlike pointers? As long as they
work... :)
----
Server IP: 66.163.161.117
Probable Submitter: 217.30.156.35
----
Manual Page -- http://www.php.net/manual/en/language.references.arent.php
Edit -- https://master.php.net/note/edit/71170
Del: integrated -- https://master.php.net/note/delete/71170/integrated
Del: useless -- https://master.php.net/note/delete/71170/useless
Del: bad code -- https://master.php.net/note/delete/71170/bad+code
Del: spam -- https://master.php.net/note/delete/71170/spam
Del: non-english -- https://master.php.net/note/delete/71170/non-english
Del: in docs -- https://master.php.net/note/delete/71170/in+docs
Del: other reasons-- https://master.php.net/note/delete/71170
Reject -- https://master.php.net/note/reject/71170
Search -- https://master.php.net/manage/user-notes.php