跳转到主内容
websoft网络软件专家 - 深耕网络技术,打造实用软件!

关于include的变量运用

关于include的变量使用 有2个文件: 1、index. php 2、index.controller.php 在index.php 里面声明了一个变量 $method; 在index.php 里面 include 了 index.controller.php. 请问在index.controller.php 里面 class index_controller类里面的方法 如何使用$method 我是判断该方法在不在。 index.php Code:

$method = show;
index.controller.php Code:

class index_controller {
function __construct()
{
if(!method_exists($this,$method)){
exit("不存在的方法");
}
}
}
------解决方案-------------------- 构造函数中获取不到$method的值,申明global 或者传递进去。

相关文章