Jump to content


Photo

What is the => Operator?


  • Please log in to reply
1 reply to this topic

#1 utahcon

utahcon
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 18 April 2006 - 03:44 PM

Ok I am looking through some code... so I need to know something.

I see this in my code

$SESSION['variable']->user->ID

Is this calling the user ID for the $SESSION['variable']?

Also what does this do

$_SESSION['variable']->user->ID as $site_ID => $site_info

Thanks!

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 18 April 2006 - 04:30 PM

ok, the pointer (->) operator is completely different from the "=>" operator. the second is mainly used with arrays. it shows the relationship between a key and its value. for instance, if we were assigning an associative array, we would do something like this:
$favorites = array("candy" => "chocolate", "color" => "blue");

this then assigns the value of "chocolate" to $favorites["candy"] and so forth.

you use the same operator when you're pulling information OUT of an array:
foreach ($favorites as $key => $value) {
  echo "$key contains \"$value\"<br />\n";
}

as for the pointer (->) operator, you need to read up on OOP (Object Oriented Programming) to get a full realization of what all is involved with something like that.

hope this helps!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users