PHP调用另一文件中的类

来源:互联网 发布:商品价格比较软件 编辑:程序博客网 时间:2024/06/15 03:12

首先在一个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;?>
0 0