thinkphp51初始化方法initialize

此方法是在所有方法之前被调用的.


class Index extends Controller
{

    public function _initialize()
    {
        echo 'init<br/>';
    }
    
    public function hello()
    {
        return 'hello';
    }
    
    public function data()
    {
        return 'data';
    }
}
调用hello方法 显示init hello.
调用data方法 显示init data.
他是老大.其他都是小弟可以这么理解
 
原文地址:https://www.cnblogs.com/xm666/p/10594500.html