www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP, what's the difference between passng a variable by its value vs memory location?

  1. #1
    Join Date
    Feb 2012
    Location
    Sacramento, CA
    Posts
    64

    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?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    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

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles