How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

August 25, 2011

What is the & Ampersand Preceding Variables – reference – php &$

Filed under: Php — admin @ 4:40 pm

You may see PHP code snippets that have an ampersand, ‘&’, preceding a variable like &$examplevar.

So, what does it do? It sets up a reference to the original variable instead of copying it’s value.


$orig = “something 1”;

$reference = &$orig;

echo $reference  // will output “something 1”

Now if we change the $orig with something else

$orig = “something 2”;

echo $reference // will output “something 2”

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress