Difference between -> and => in PHP

Arrow Operator ->

The arrow operator ( -> ) is used to call method and access property of an object

$obj = new StdClass;
$obj->foo = 'bar';

Double Arrow =>

The double arrow operator is used to set key value pairs in an array

$array = array(
    'foo' => 'bar'
);
var_dump($array);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.