-1

I want to know how is value passed in php by default. Is it by reference or is it by value. I did a search and found that some say it's value only and some say its reference by default. I understand its not a programming question but i need the answer for my recruitment interview.

Some say reference: Clarification of PHP manual; default values passed by reference

Some say Value: Are PHP Variables passed by value or by reference?

Community
  • 1
  • 1
Arihant
  • 3,847
  • 16
  • 55
  • 86
  • To allow for more confusion, "the reference is passed by value" is another option, which I _think_ PHP uses. – Izkata Oct 02 '13 at 19:00
  • [Here](https://www.youtube.com/watch?v=_YZIBWQr_yk) is a little YT video from SO member. – Glavić Oct 02 '13 at 19:10

1 Answers1

3

Variables are passed by value. However, the value of a variable pointing to an object is the address of the object, not the object itself, so objects passed as method parameters are not copied; both the calling context and method will share the same object instance.

deceze
  • 510,633
  • 85
  • 743
  • 889
user229044
  • 232,980
  • 40
  • 330
  • 338