好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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中文网!

以上就是php调用类的方法的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于php调用类的方法的详细内容...

  阅读:50次