"; the "->" symbol is an inserted dereference operator, which is used to call member attributes and methods of an object. It is a method of calling subroutines that pass parameters by reference. The syntax is "class name->method"."/> "; the "->" symbol is an inserted dereference operator, which is used to call member attributes and methods of an object. It is a method of calling subroutines that pass parameters by reference. The syntax is "class name->method".">
Home > Article > Backend Development > What is the symbol for calling class methods in php
In PHP, the symbol for calling class methods is "->"; the "->" symbol is an inserted dereference operator, which is used to call member properties and methods of an object. It is called by a reference. The method of the subroutine that passes parameters, the syntax is "class name->method".
The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer
'- >' symbol is the "infix dereference operator". In other words, it is a method that calls a subroutine whose parameters are passed by reference (among other things, of course). As we mentioned above, when calling PHP functions, most parameters are passed by reference. The '->' functions in PHP are just like they are in Perl or C. The following is a simple dereference example:
echo $x->def(); # The output
example is as follows:
First, in a tool Declare a class in the .php file:
<?php class tool { function say(){ $result="Hello,World"; return $result; } }
Call the method in the above class in another file main.php:
<?php require_once 'tool.php'; $tool=new tool(); $content=$tool->say(); echo $content; ?>
Recommended learning: "PHP Video Tutorial 》
The above is the detailed content of What is the symbol for calling class methods in php. For more information, please follow other related articles on the PHP Chinese website!