php调用类的方法

php调用类的方法
在本片文章中给大家详细分享了PHP程序中去调用另外一个文件类的方法和代码写法,一起学习下。
首先在一个tool.php文件中声明一个类:
<?php
class tool {
function say(){
$result="Hello,World";
return $result;
}
}
在另一文件main.php调用上面的类中的方法:
<?php
require_once 'tool.php';
$tool=new tool();
$content=$tool->say();
echo $content;
?>
!
以上就是php调用类的方法的详细内容,更多请关注其它相关文章!
相关推荐
-
第18问:MySQL CPU 高了,怎么办?2025-02-24 10:27:18
-
mysql索引类型 normal, unique, full text
mysql索引类型 normal, unique, full text2025-02-24 10:05:05 -
uwsgi+django+nginx 搭建部分总结2025-02-24 10:03:33
-
使用Docker配置Nginx环境部署Nextcloud2025-02-24 10:02:03
-
Nginx安装和怎么使用2025-02-24 10:00:45