您的位置 首页 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调用类的方法

文章地址:https://www.zhihuclub.com/78188.shtml

关于作者: 智云科技

热门文章

网站地图