Home  >  Article  >  Backend Development  >  What is the method of calling file class in php

What is the method of calling file class in php

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-27 10:47:274480browse

What is the method of calling file class in php

This time I will show you how to make a calling file class in PHP, and what are the precautions for making a calling file class in PHP. The following is a practical case, let's take a look.

Related recommendations: "PHP Tutorial"

First declare a class in a tool.php file:

<?php
  class tool {
  function say(){
  $result="Hello,World";
  return $result;
  }
}

In another file main. PHP calls the method in the above class:

<?php
  require_once &#39;tool.php&#39;;
  $tool=new tool();
  $content=$tool->say();
  echo $content;
?>

The above is the detailed content of What is the method of calling file class 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