Newbie Alert :D

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Superphil
Forum Newbie
Posts: 3
Joined: Tue Jun 08, 2010 11:59 am

Newbie Alert :D

Post 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
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Newbie Alert :D

Post 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.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Newbie Alert :D

Post 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.
User avatar
StedeTroisi
Forum Newbie
Posts: 2
Joined: Wed Jun 09, 2010 6:55 pm

Re: Newbie Alert :D

Post 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.
Post Reply