Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
Can someone please explain to me (preferably in simple English) what references are? I looked at the PHP manual, but I don't understand a thing. I am especially interested in the "&" symbol and what it allows me to do. From what I can see,
$y is an alias for $x. Any further changes to $y would be reflected to $x as well
Yes, that is exactly the explanation I needed. I was considering putting "in simple English or Russian", but decided not to, didn't realize there were people who spoke Russian here. Spasibo!
Oh, one more thing. Are changes to $x reflected on $y?
evilmonkey wrote:
Yes, that is exactly the explanation I needed. I was considering putting "in simple English or Russian", but decided not to, didn't realize there were people who spoke Russian here. Spasibo!
Bez problem [Moderator's hat on]
However we speak English here [Moderator's hat off]
evilmonkey wrote:
Oh, one more thing. Are changes to $x reflected on $y?
Yes, they are. In fact when $y is a reference to $x you could use both interchangeably.
Last edited by Weirdan on Thu Nov 24, 2005 10:59 am, edited 2 times in total.
$somevar = 5;
function foobar($somevar){
//this is called passing by reference
//What ever you do to $somevar in the function is reflected outside the function
$somevar = 12;
}
foobar(&$somevar);
echo $somevar; //outputs 12