The arrow symbol of php is called the arrow operator. The left side of the arrow operator is to obtain the instance of the class, and the right side will specify and call the methods and attributes of the left class.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
The arrow of php refers to What does it mean?
#What is the usage of php arrow?
The "->" symbol in php is called the arrow operator. The left side of the arrow operator is to get the instance of the class, and the right side will specify and call the methods and attributes of the left class. , in this article we will introduce the usage of arrow operators in php.
Use the -> symbol to reference the properties and methods of a class. -> means calling
Syntax:
We use sample code below to illustrate the arrow operator in PHP.
The syntax defined is as follows.
Next is "instance", but this refers to an instance created from the defined class, which corresponds to the template above. If you specify the new operator and write it as classname(), an instance will be created.
<?php $a=www.xiaoyuani.com; $b=xiaoyuani.com; $c=3; echo $a+$b.' '; echo $a-$b.' '; echo $a*$b.' '; echo $a/$b.' '; echo $a%$c.' '; $a++; echo $a.' '; ++$a; echo $a.' '; $c--; echo $c; 在以下示例中,生成的实例将分配给变量$ instance。 箭头运算符写法 箭头操作符的使用示例如下所示。 以下代码访问“属性名1”和“属性名2” 以下代码调用“方法1”和“方法2” 我们来看具体的示例 让我们在上面的例句中用箭头操作符显式指定类名,属性名,方法名,方法中的处理,以及访问每个项。 这次我们定义一个人(Person)类,其名称(name)作为属性,自我介绍(introductionSelf)作为方法。 此外,出现的__construct( )是使用new运算符创建实例时要执行的特殊方法。
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does the arrow in php mean?. For more information, please follow other related articles on the PHP Chinese website!