Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Clarification on &$somevar usage

    I am not sure so I am making an assumption (and I can't think of a good way to test it) that the use of & in front of the variable is a pointer to the original variable? The case in point is from an article I was reading.
    PHP Code:
     $this->source = &$_REQUEST
    So I read this as assigning the source variable in the class with a pointer to the $_REQUEST variable. Is this correct? Can you give me another example of the use?

    Thanks
    Scott Stewart
    Always happy to learn from pros.

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    It's always dangerous to say things a certain way with programming languages.

    The basic idea is that $this->source will add a new entry in the variable table that points to the same content as $_REQUEST.

    I don't think it would be right to say though that it is a pointer, and that it behaves similar. Your best bet is to look at the PHP manual [references explained], as it has the best information out there. And you generally don't need more.

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks. The info you pointed to was quite useful.
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

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