Home > Backend Development > PHP Problem > What does the arrow in php mean?

What does the arrow in php mean?

藏色散人
Release: 2023-03-13 19:28:02
Original
2856 people have browsed it

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.

What does the arrow in php mean?

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.

What does the arrow in php mean?

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.&#39;
&#39;; echo $a-$b.&#39;
&#39;; echo $a*$b.&#39;
&#39;; echo $a/$b.&#39;
&#39;; echo $a%$c.&#39;
&#39;; $a++; echo $a.&#39;
&#39;; ++$a; echo $a.&#39;
&#39;; $c--; echo $c; 
在以下示例中,生成的实例将分配给变量$ instance。 箭头运算符写法 箭头操作符的使用示例如下所示。 
以下代码访问“属性名1”和“属性名2” 以下代码调用“方法1”和“方法2” 我们来看具体的示例 让我们在上面的例句中用箭头操作符显式指定类名,属性名,方法名,方法中的处理,以及访问每个项。 
这次我们定义一个人(Person)类,其名称(name)作为属性,自我介绍(introductionSelf)作为方法。 此外,出现的__construct( )是使用new运算符创建实例时要执行的特殊方法。
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template