// 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();
// The double arrow operator, =>, is used as an access mechanism for arrays.
$myArray = array(
0 => 'Big',
1 => 'Small',
2 => 'Up',
3 => 'Down'
);
// The object operator, ->, is used in object scope to access methods and properties of an object.
$obj = new MyObject(); // create a new instance of MyObject into $obj
$obj->thisProperty = 'Fred'; // set a property in the $obj object called thisProperty
$obj->getProperty(); // call a method of the $obj object named getProperty
PHP =>
//The double arrow operator, =>
//Used as an access mechanism for arrays.
//The left side will have a corresponding value on the right side in array.
//This can be used to set values into a corresponding index of an array.
//The index can be a string or number.
$myArray = array(
0 => 'Red',
1 => 'Orange',
2 => 'Yellow',
3 => 'Green'
);
// 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();
/* <?= ?> is a shorthand for */
<?php echo "something"; ?>
// Above code is the same as:
<?= "something" ?>