To the C/C++ coder, PHP references are bit challenging to understand. Are they pointers?
Regardless of the way references do truly work, what confuses the C/C++ coder is that it seems that PHP references are not like pointers because of the syntax:
int i, *p; i = 0; p = &i; std::cout << *p; // In PHP, you would write p and not *p
As in :
$i = 0; $p = &$i; echo ($p); // See: that's $p as if it was like $i
So, how should the C/C++ coder understand how references do work in PHP ? The purpose of this article is to cast some light on this. More broadly speaking, anyone who intends to use references in PHP should find something interesting here - most notably to clarify the relationship between reference and
unset ()
.
Ciquez ici pour lire cet article en français.
Continue reading "Are PHP references C/C++ pointers?"