By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

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

P: n/a
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) {
$engine->do_themefooter($index);
}

}
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
appreciated.

thanks,
brett.

May 16 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
*** pl*********@gmail.com escribió/wrote (16 May 2007 13:55:14 -0700):
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.
->

http://es2.php.net/manual/en/function.array.php

=>

http://es2.php.net/manual/en/language.oop.php

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
--
May 16 '07 #2

P: n/a
On May 16, 3:55 pm, planetbr...@gmail.com wrote:
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) {
$engine->do_themefooter($index);
}

}
The -return the attribute or calls the methods of an object The
above example calls the do_themefooter() method of whatever class
$engine is.
>
Example 2:

// get the color scheme
$colors = pnModAPIFunc('Xanthia','user','getSkinColors',
array('skinid' =$skinID,
'paletteid' =$paletteid));
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:
$colors['skinid']
>
If anyone can shed some light on this, it would be greatly
appreciated.

thanks,
brett.

May 17 '07 #3

P: n/a
On May 16, 4:55 pm, planetbr...@gmail.com wrote:
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) {
$engine->do_themefooter($index);
}

}

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
appreciated.

thanks,
brett.
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
programming.
$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.

Trey

May 17 '07 #4

P: n/a
Message-ID: <11**********************@e65g2000hsc.googlegroups .comfrom
th******@gmail.com contained the following:
Ex. $array('skinid' =$skinID);
This technique is pretty frequent in certain circumstances. So
$array['skinid'] refers to the value of $skinID.
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/
May 17 '07 #5

P: n/a
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
May 17 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.