首页 > 编程 > PHP > 正文

PHP调用其他文件中的类

2019-11-21 20:32:01
字体:
来源:转载
供稿:网友

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

以上就是本次给大家介绍的互相引用类的方法,感谢大家对武林网的支持。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表