Page 1 of 1

what does "->" mean

Posted: Thu Nov 26, 2009 9:16 am
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. :?

Re: what does "->" mean

Posted: Thu Nov 26, 2009 9:42 am
by dimebag
its nested functions in each other in that class
so its inheriting until it reach to last one

Re: what does "->" mean

Posted: Thu Nov 26, 2009 9:50 am
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.

Re: what does "->" mean

Posted: Thu Nov 26, 2009 10:39 am
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();