" and "=>" do? "/>

what does "->" and "=>" do?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have read through php.net manuals and have not see any mention about
what these operands actually do.  I have seen them used in a bunch of
different code lately and don't really understand.

Example 1:

// Legacy Function: Renders the Footer of the Theme
function themefooter() {
    global $engine, $index, $themepath;

    if ($index != 3) {


Example 2:

// get the color scheme
$colors = pnModAPIFunc('Xanthia','user','getSkinColors',
            array('skinid' => $skinID,
            'paletteid' => $paletteid));

If anyone can shed some light on this, it would be greatly


Re: what does "->" and "=>" do?

*** planetbrett@gmail.com escribió/wrote (16 May 2007 13:55:14 -0700):
Quoted text here. Click to load it





Hope this helps,

-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com

Re: what does "->" and "=>" do?

On May 16, 3:55 pm, planetbr...@gmail.com wrote:
Quoted text here. Click to load it
The -> return the attribute or calls the methods of an object The
above example calls the do_themefooter() method of whatever class
$engine is.
Quoted text here. Click to load it
That's an array. The => means the the string on the right side (the
key) refers to the value on the left. You could access the value of
$skinID, for example like this:
Quoted text here. Click to load it

Re: what does "->" and "=>" do?

On May 16, 4:55 pm, planetbr...@gmail.com wrote:
Quoted text here. Click to load it

Ok brett its pretty simple the difference between the two. In this
particular circumstance the two operators are used for very different
things. Example 1 is  a C like operator. Almost like an object in OOP
$engine is like a pointer to the value do_themefooter($index);
returns. Which is what happens in this sense.

Example 2
This is one of many ways to populate an array in php.
Instead of populating the array with a number based index, They have
chosen to populate the array using names instead of numbers. Ex.
$array[0] = "whatever";
                 Ex. $array('skinid' => $skinID);
This technique is pretty frequent in certain circumstances. So
$array['skinid'] refers to the value of $skinID.

Hope this was helpful.


Re: what does "->" and "=>" do?

thaertel@gmail.com contained the following:

Quoted text here. Click to load it

I call it an 'andits'  As in

$key andits $value


Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Re: what does "->" and "=>" do?

thaertel wrote:

Quoted text here. Click to load it

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 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
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux

Site Timeline