Home > Article > Backend Development > How to make a calling file class in PHP
This time I will show you how to make a calling file class in PHP. What are the precautions for making a calling file class in PHP? The following is a practical case, let's take a look.
First declare a class in a tool.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; ?>I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website ! Recommended reading: ##yii2 resetful’s authorization verification detailed explanationHow to prevent XSS cross-site attacks in Laravel 5
The above is the detailed content of How to make a calling file class in PHP. For more information, please follow other related articles on the PHP Chinese website!