In PHP, what is the difference between using a pointer such as:
function foo( $var )
{
$var = 3;
}
$a = 0;
foo( &$a );
And reference:
function foo( &$var )
{
$var = 3;
}
$a = 0;
foo( $a );
They both modify the value of the original variable, but are they represented differently internally?
In PHP, there are no pointers, only references. Your examples demonstrate pass by reference
The difference between your code snippets is only in syntax, where the first syntax is now deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With