PHP, what's the difference between passng a variable by its value vs memory location?
I was asked this in an interview, he expained that if I put a return statement in my function it will return the value, but in that case is the variable being passed by value or memory location?
Also, you elaborate in a little more on passing variable values?
I don't know if there's a (meaningful) way to pass a variable my memory location like you might with a C pointer, but you can pass them by reference (see the "&" operator) which is very similar, though a few technical differences deep down in the weeds. Note that in PHP 5+, objects are passed by reference by default now.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)