|
Posted by mejpark on 08/22/07 23:21
On Aug 13, 1:15 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> mejpark wrote:
> > What is thedifferencebetween " => " and " -> " in PHP?
>
> '=>' is used when filling an array to provide an explicit key for a value.
> e.g.:
>
> $team = array(
> 'Bob',
> 'Steve',
> 'Dave',
> 'manager'=>'Harry'
> );
>
> is roughly equivalent to:
>
> $team = array();
> $team[0] = 'Bob';
> $team[1] = 'Steve';
> $team[2] = 'Dave';
> $team['manager'] = 'Harry';
>
> '->' is an entirely different operator. It has nothing to do with arrays.
> It it used to reference an object property or method in object-oriented
> programming. It is equivalent to Java's "." operator. e.g.
>
> $myCup = new Cup($cupsize);
> echo $myCup->fill(LIQUIDS_ORANGE_JUICE, '300 mL');
> if ($myCup->percentageFilled==100)
> {
> echo "Cup is full.\n";
> if ($myCup->hasOverflowed)
> echo "Cup has overflowed!\n";
> }
> else
> {
> echo "There's still room for vodka!\n";
> }
>
> --
> Toby A Inkster BSc (Hons) ARCS
> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> [OS: Linux 2.6.12-12mdksmp, up 53 days, 15:46.]
>
> PHP Debugging with Style -OR- How I Learned to Stop Worrying and Love the Bug
> http://tobyinkster.co.uk/blog/2007/08/12/php-debugging-with-style/
Haha, very amusing example! Thankyou both for your explanations, that
has clarified thin gs in my mind! Right, back to ACLs and the Star
Wars example then!
Navigation:
[Reply to this message]
|