Introduction
In this article I will explain references in PHP. References are not pointers. In PHP references are a way to access the same variable content using a different name. PHP reference are not like C pointers,
for instance, you cannot perform pointer arithmetic using them, they are not actual memory addresses. There are three basic operations performed using references, such as assigning by reference, passing by reference, and returning by reference. and so on.
Example
<?php
$foo = 'Hello';
$bar = 'World';
echo $foo."<br>";
echo $bar;
?>
Output


<?php
$bar = & $foo;
?>

Returning References
The following is an example of passing arguments to a function by reference:
Example
<?php
function inc(& $b) {
$b++;
}
$a = 1;
inc($a);



Vinod KumarPosted Mar 25, 2013, 6:12 AM
but sir php references are not like pointer and references in PHP are a means to access the same variable content by different names. They are not like C++ pointers for instance, you cannot perform pointer arithmetic using them,they are not actual memory addresses.
Sam HobbsPosted Mar 24, 2013, 9:49 PM
How do PHP references compare to C++ references? Note that in C++ references are like pointers except references use a different syntax that makes them easier and safer to use. For example, references in C++ also cannot be evaluated in the manner that pointers are in pointer arithmetic. I assume that PHP references are like C++ references.