What does this mean in PHP & # 8594; or =>
Possible duplicate:
where we use the object operator "->" in php
Link - what does this symbol mean in PHP?
I see this all the time in PHP, but I have no clue as to what they really mean. What does -> and what does => . And I'm not talking about operators. They are something else, but no one seems to know ...
The double arrow operator, => used as an access mechanism for arrays. This means that what is on the left side will have the corresponding value of what is to the right of it in the context of the array. This can be used to set values ββof any acceptable type to the corresponding array index. An index can be associative (string) or numeric.
$myArray = array( 0 => 'Big', 1 => 'Small', 2 => 'Up', 3 => 'Down' ); Object Operator , -> used in the object area to access the methods and properties of the object. Its meaning is to say that what is to the right of the operator is a member of the object created in the variable to the left of the operator. This is the key term here.
// Create a new instance of MyObject into $obj $obj = new MyObject(); // Set a property in the $obj object called thisProperty $obj->thisProperty = 'Fred'; // Call a method of the $obj object named getProperty $obj->getProperty(); => used in assigning a value to an associative array. Take a look at:
http://php.net/manual/en/language.types.array.php .
-> used to access a method object or property. Example: $obj->method() .
β
calls / sets object variables. Example:
$obj = new StdClass; $obj->foo = 'bar'; var_dump($obj); => Sets key / value pairs for arrays. Example:
$array = array( 'foo' => 'bar' ); var_dump($array); -> a method call is used on the class object
=> used to assign values ββto array keys
as
$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34, 1=>2);