note 58222 deleted from language.references.arent by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 14:54:22 +0000 |
| Subject: | note 58222 deleted from language.references.arent by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197219@lists.php.net to get a copy of this message | ||
Note Submitter: DanielSan88
----
I can see why there is a big debate on this. I'm hoping this will clarify it a little.
In PHP, as far as I can understand, when you assign a variable in the first place,
that variable is a refrence to the value that the variable contains.
<?php
$var = "String"; // Creates the string "String" somewhere in memory.
echo $var;
/* When the echo function is called, it pulls the value of $var out of memory from wherever PHP
decided to put it.
PHP then ships this value off to your standard output. */
?>
Anyway, when you create a reference to the variable $var,
it doesn't reference the variable's name, but rather its contents.
For example:
<?php
$var2 = & $var;
echo $var2;
/* Calling this echo does ecactly the same thing as the echo in the code snippet above this one.
Whether you echo $var or $var2, the same string in memory is sent to your standard output. */
?>
In the same sense of an array, $var and $var2 are like keys to the same value. The value being the
string in memory.
When you call a function that uses a reference, the reference is not less than the variable given as
the argument, or anything more than it.
It is that same variable except with a different name.