宝玛科技网
您的当前位置:首页php调用类的方法

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相关知识,请访问PHP中文网!

显示全文