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

What is the method of calling file class in php

爱喝马黛茶的安东尼
Release: 2023-02-23 11:16:01
Original
4618 people have browsed it

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;
  }
}
Copy after login

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;
?>
Copy after login

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!

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