Home Tutorial Php Phpoop PHP References Explained

 
 

PHP References Explained
Posted on: March 5, 2010 at 12:00 AM
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

Related Tags for PHP References Explained:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.