" operator is a method for operating member variables in a class. It accesses functions or objects in the class as an instantiated object, such as "$runoob->getUrl();"; while "=>" is The operator used when mapping the key and value of an array. The syntax "index=>values" can be used to assign values to keys."/> " operator is a method for operating member variables in a class. It accesses functions or objects in the class as an instantiated object, such as "$runoob->getUrl();"; while "=>" is The operator used when mapping the key and value of an array. The syntax "index=>values" can be used to assign values to keys.">
Home > Article > Backend Development > What is the difference between -> and => operators in php
Difference: The "->" operator is a method for operating member variables in a class. It accesses functions or objects in the class as an instantiated object, for example "$runoob->getUrl(); "; and "=>" is the operator used when mapping the key and value of the array. The syntax "index=>values" can assign values to the keys.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
##“-> "Operator
This operator is a method to operate member variables in a class, which can be non-static member variables, such as:class xxx{ private $test; $this-test="111"; }
"=>"Operator
This operator is used when mapping the key and value of an array. The syntax "index => values", separated by commas, defines the index and value.
The difference between -> and => operators in PHP
In PHP, the => operator is usually used for arrays During operation, the general form is as follows:$arr = array(key=>value,key2=>value2);Assign a value to the key in the array. The key can be an integer or a string, and the value can be any type of value. This operator is easily confused with greater than or equal to (>=), please note. And->Access functions or objects in the class as instantiated objects, for example:
$runoob->getUrl();Recommended learning: "
PHP Video Tutorial"
The above is the detailed content of What is the difference between -> and => operators in php. For more information, please follow other related articles on the PHP Chinese website!