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 6 of 6
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Lightbulb what are -> in code ?

    Been going through some code, but I've never learned what the -> arrows meant, can anyone please explain how they are use.. examples:


    PHP Code:
    $row $db->getRow $query ); 
    or

    PHP Code:
    if ( $row->Active == 
    (but why cant you just do like $active == 1 instead?)

    Thanks

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    It means you're accessing a function or variable in a class.

  • #3
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by MattF View Post
    It means you're accessing a function or variable in a class.
    This is mostly correct. -> is used for scope access on an instance of a class - an object itself. PHP does not variable mask, so it is a requirement when accessing $this from an object context. Accessing members and methods inside a class itself is done statically with the paamayim nekudotayim operator (::).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Quote Originally Posted by Fou-Lu View Post
    paamayim nekudotayim operator (::).
    Or double colon for those not versed in hebrew
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by JAY6390 View Post
    Or double colon for those not versed in hebrew
    Yeah, hah hah. Apparently it actually means double colon in hebrew, but I'm afraid I cannot confirm that. Google translate has no result for it :P
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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