Difference between -> and => in PHP

Published by arifur on

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);


0 Comments

Leave a Reply

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