what does "->" mean

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
krusmal
Forum Newbie
Posts: 2
Joined: Thu Nov 26, 2009 9:09 am

what does "->" mean

Post by krusmal »

Hi,
I am new to PHP and am trying my hands on Object Oriented PHP. I need a little help on the symbol ->

I know how to use -> symbol. But I have seen some typical examples of it which I dont understand. Please check the following example and somebody tell me what actually it all means and what class structure it is used for:

Code: Select all

Example::instance()->foo()->bar()->get()->something();
Please tell me the meaning of the multiple -> symbols in a single statement. I hope it is not a silly question. :?
dimebag
Forum Newbie
Posts: 22
Joined: Fri Feb 13, 2009 4:13 pm

Re: what does "->" mean

Post by dimebag »

its nested functions in each other in that class
so its inheriting until it reach to last one
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: what does "->" mean

Post by pickle »

Example::instance() returns an object. That object has a method called foo(). foo() also returns an object. That object has a method called bar(). bar() also returns an object... and so on.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
krusmal
Forum Newbie
Posts: 2
Joined: Thu Nov 26, 2009 9:09 am

Re: what does "->" mean

Post by krusmal »

Thanks Friends. It is somewhat helpful.

I would love and be greatful if anyone writes a few lines of code to demonstrate the line which I have mentioned

Code: Select all

Example::instance()->foo()->bar()->get()->something();
Post Reply