...

View Full Version : what are -> in code ?



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



$row = $db->getRow ( $query );

or


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

Thanks ;)

MattF
02-07-2010, 05:05 PM
It means you're accessing a function or variable in a class.

Dormilich
02-08-2010, 07:50 AM
see also PHP’s Introduction to Object Oriented Programming (http://php.net/oop)

Fou-Lu
02-08-2010, 12:17 PM
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 (::).

JAY6390
02-08-2010, 01:12 PM
paamayim nekudotayim operator (::).Or double colon for those not versed in hebrew :D

Fou-Lu
02-08-2010, 01:15 PM
Or double colon for those not versed in hebrew :D

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum