You are here: Re: what does "->" and "=>" do? « PHP Programming Language « IT news, forums, messages
Re: what does "->" and "=>" do?

Posted by Toby A Inkster on 05/17/07 12:38

thaertel wrote:

> Example 1 is a C like operator. Almost like an object in OOP
> programming. $engine is like a pointer to the value
> do_themefooter($index); returns. Which is what happens in this sense.

It's not "almost like" an object.

It is the operator that allows you to access properties and methods of an
object. It's analogous to the square brackets when using arrays.

$foo['bar'] is to arrays
As $foo->bar is to objects.

Despite looking like a little arrow, it's not got anything to do with
pointers in a C sense of the word. $engine isn't a pointer to the value
do_themefooter($index) returns.

$engine is an object -- a "thing" of some kind, and it has a method
do_themefooter(). A "method" is just "something that an object is capable
of doing". So "$engine->do_themefooter()" just means: ask $engine to
perform its "do_themefooter()" action. Like this:

$dog->chase($cat);

Dog isn't a "pointer to the cat chasing function". Dog is the thing that's
actively doing the chasing.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация