日期:2014-05-17  浏览次数:20425 次

关于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 或者传递进去。