Share on Google+Share on Google+

PHP References Explained

Advertisement
This tutorial covers three basic operations performed by references, assigning values by references, passing by references, returning by references etc. In PHP references means to access the same variable by two or more different names.

References In PHP:

What PHP References are?

In PHP references  means to access the same variable by two or more different names. References are not like  C pointers means these are not for storing address or any other pointer arithmetic. The references can be linked to hardlinking in Unix filesystem. 

This tutorial covers three basic operations performed by references, assigning values by references, passing by references, returning by references etc.

Assign by reference:

PHP Reference Example:

<?php

$var1=12;

$var2=&$var1;

echo "Value of \$var1:".$var1."<br/>";

echo "Value of \$var2:".$var2."<br/>";

?>

Output:

Value of $var1:12
Value of $var2:12

Advertisements

Advertisement

Posted on: March 5, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.