Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default whats the & in php?

    Okay say i have this in a class

    $this->db = &$db;

    whats the & do??

  2. #2
    Join Date
    Apr 2005
    Location
    Nottingham
    Posts
    9,691
    Tokens
    918

    Latest Awards:


  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    It makes $this->db a reference of $db.

  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    I think the best way to explain it is, its an alias. A nickname to a person if you will.


    www.fragme.co = a project.

  5. #5
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Try learning the operators.

    http://uk2.php.net/operators

  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    It's called references, although I like to refer to them as aliases (don't ask ;P).

    It basically means this:

    PHP Code:
    $a 1;
    $b $a
    When you set $b to be $a, it sets the value of $b to 1, until you change it.

    When you do this:

    PHP Code:
    $a 1;
    $b = & $a;

    $a 2// means $b will also be 2, as it is a reference of $a. 
    $b is just another name for $a.

  7. #7
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    I didn't know this.

    thanks


  8. #8
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    Quote Originally Posted by Dentafrice View Post
    It's called references, although I like to refer to them as aliases (don't ask ;P).

    It basically means this:

    PHP Code:
    $a 1;
    $b $a
    When you set $b to be $a, it sets the value of $b to 1, until you change it.

    When you do this:

    PHP Code:
    $a 1;
    $b = & $a;

    $a 2// means $b will also be 2, as it is a reference of $a. 
    $b is just another name for $a.
    Thank you i have done it to my scripts as with out it, it never worked now i know why i am happy

  9. #9
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    It's called references, although I like to refer to them as aliases (don't ask ;P).

    It basically means this:

    PHP Code:
    $a 1;
    $b $a
    When you set $b to be $a, it sets the value of $b to 1, until you change it.

    When you do this:

    PHP Code:
    $a 1;
    $b = & $a;

    $a 2// means $b will also be 2, as it is a reference of $a. 
    $b is just another name for $a.
    Ah, that clears things up, thanks.
    How could this hapen to meeeeeeeeeeeeeee?lol.

Posting Permissions

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