What -> means in PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
dv_evan
Forum Commoner
Posts: 42
Joined: Wed Apr 09, 2008 8:23 am

What -> means in PHP

Post by dv_evan »

Hello all,

I know to many experience programmer of which I am not will sound crazy. What does -> means in php, I have come across this in many codes and came up empty trying to research what this is?

Kindly explain.
Dave
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: What -> means in PHP

Post by nowaydown1 »

Greetings. It means that you're trying to use a specific method or parameter on an object. For example:

Code: Select all

 
$myCar = new Car();
$myCar->start();
 
Would call the start() method on the instantiated Car object.
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: What -> means in PHP

Post by panic! »

Hi it means you're using a property or method of a class so for example:

Code: Select all

 
 
$cat=new Cat();
 
$cat->meow(); // tell the cat to meow
 
print $cat->age;  //print the cat's age
 
print $cat->name; //print the cat's name
 
print $cat->fleas[0]->name //print the name of the first of the cat's fleas.
 
$cat->scratch();
 
 
Post Reply