Page 1 of 1

Newbie Alert :D

Posted: Tue Jun 08, 2010 12:05 pm
by Superphil
Hello, I'm teaching myself php and I came across a problem while learning.

Normally I could google a question, but I can't seem to find anything explaining to me what "->" means. I tried googling, "what does -> mean in php" with no avail. I know it has something to do with assigning data to a variable, but I can't seem to figure out why it is used.

Any explanation would be greatly appreciated!

EDIT: WOW, someone posted this exact question a few minutes ago! Sorry, I didn't see it in time

Re: Newbie Alert :D

Posted: Tue Jun 08, 2010 3:40 pm
by JakeJ
Do a tutorial on object oriented PHP and you'll see what it means. since you're learning PHP you would be well advised to do that anyway.

Re: Newbie Alert :D

Posted: Wed Jun 09, 2010 8:06 am
by cpetercarter
"->" is used in object oriented php. An explanation may not mean much unless you first read up a bit about oop in php; but briefly

Code: Select all

$a->$b
is a reference to the property $b of the object $a; while

Code: Select all

$a->$b()
is a reference to the method (function) $b of the object $a.

Re: Newbie Alert :D

Posted: Wed Jun 09, 2010 7:04 pm
by StedeTroisi
Before learning OOP, just learn regular PHP. It might be all you need. Remember one word: YAGNI. It means you ain't going to need it.