1// Create a new instance of MyObject into $obj
2$obj = new MyObject();
3// Set a property in the $obj object called thisProperty
4$obj->thisProperty = 'Fred';
5// Call a method of the $obj object named getProperty
6$obj->getProperty();
1PHP =>
2 //The double arrow operator, =>
3 //Used as an access mechanism for arrays.
4 //The left side will have a corresponding value on the right side in array.
5 //This can be used to set values into a corresponding index of an array.
6 //The index can be a string or number.
7$myArray = array(
8 0 => 'Red',
9 1 => 'Orange',
10 2 => 'Yellow',
11 3 => 'Green'
12);
1//The -> operator, also known as the object operator is used to access the properties and methods for a specific object.
2// Besides, in simple words, the object operator -> is responsible for accessing an object method.
3// for example: you a class 'Point' with a 'calculatePoint' method
4$obj = new Point();
5// setting a property of the Point class
6$obj->x = 'value';
7$obj->y = 'value';
8// Calling a any method from our $obj
9$obj->calculatePoint();
10
11// Same implementation in Python
12pyoObj = Point()
13pyObj.x = 'value'
14pyObj.y = 'value'
15
16pyObj.calculatePoint()
17
18// you should have something like that in most languages,
19 // I mean the '.propery()' instead of '->property()'
1// Create a new instance of MyObject into $obj
2$obj = new MyObject();
3// Set a property in the $obj object called thisProperty
4$obj->thisProperty = 'Fred';
5// Call a method of the $obj object named getProperty
6$obj->getProperty();
7