Page 1 of 1

What -> means in PHP

Posted: Fri May 30, 2008 11:25 pm
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

Re: What -> means in PHP

Posted: Fri May 30, 2008 11:57 pm
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.

Re: What -> means in PHP

Posted: Sat May 31, 2008 3:10 am
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();