PDA

View Full Version : What is '->' ?


7thGuest
Wed 20th Sep '06, 6:12pm
I've noticed a lot of PHP scripts use this:

->

(eg: $newuserid = $vbulletin->userstats['newuserid'];)

What exactly does it do?

Colin F
Wed 20th Sep '06, 7:05pm
It's used in classes, though I'm not sure what it's actually called :)
http://ch2.php.net/manual/en/language.oop5.basic.php

7thGuest
Thu 21st Sep '06, 4:38am
I did take a look at that - but I'm not too up on OOP.
The manual doesn't seem to explain it, and I can't work it out exactly from the examples...

Please can anyone elaborate?

nico_swd
Thu 21st Sep '06, 5:25am
Not only classes, basically when working with objects.



$browser = get_browser();

echo 'Cookies are '. ($browser->cookies ? 'supported' : 'not supported');



$query = mysql_query("SELECT * FROM table");

while ($row = mysql_fetch_object($query))
{
echo $row->fieldname;
}


I don't know how to call it either... maybe arrow operator?

simsim
Thu 21st Sep '06, 3:20pm
I don't know how to call it either... maybe arrow operator?
True; it's called the arrow operator:
http://ch2.php.net/manual/en/language.oop5.static.php