"; 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

What is the symbol for calling class methods in php

WBOY
WBOYOriginal
2022-02-17 10:56:103277browse

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".

What is the symbol for calling class methods in php

The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

What are the symbols for calling class methods in php

'- >' 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 &#39;tool.php&#39;;
  $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!

Statement:
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