PHP source MVC Initialization class has a SetUrl method cannot run

Source: Internet
Author: User

PrivilegeAction.class.php

Determining whether a constant is defined, if not defined, means that it is not the requested INDEX.PHPIF (!defined (' ACCESS ')) exit;//initializes class application{//1. Initialize the character set private static function SetHeader () {echo __method__.
"; Header (' Content-type:text/html;charset=utf-8 '); }//2. Initialize the system constants private static function Setconst () {echo __method__.
"; Set the root directory constant define (' Root_dir ', str_replace ('/core ', ' ', str_replace (' \ \ ', '/', __dir__))); Define other directories define (' Core_dir ', Root_dir. '/core '); Define (' Action_dir ', Root_dir. '/action '); Define (' Conf_dir ', Root_dir. '/conf '); Define (' Model_dir ', Root_dir. '/model '); Define (' View_dir ', Root_dir. '/view '); Define (' Pub_dir ', Root_dir. '/public '); }//3. Error message private static function seterrors () {echo __method__.
"; Development environment, display errors, display all levels of error//production environment, do not display errors, hide all levels of error (System to do fault-tolerant processing) @ini_set (' error_reporting ', 1); @ini_set (' display_errors ', 1); }//4. Auto Load//4.1 Load Controller class public static function Loadaction ($class) {echo __method__.
"; Determine if (Is_file (Action_dir). "/$class. class.php")) {include_once action_dir. "/$class. class.php"; }}//4.2 loads the core class public static function Loadcore ($class) {echo __method__.
"; Determine if (Is_file (Core_dir). "/$class. class.php")) {include_once core_dir. "/$class. class.php"; }}//4.3 loads the model class public static function Loadmodel ($class) {echo __method__.
"; Determine if (Is_file (Model_dir). "/$class. class.php")) {include_once model_dir. "/$class. class.php"; }}//Register all automatic loading methods in the auto-loading mechanism private static function setautoload () {echo __method__.
"; Spl_autoload_register (Array (' Application ', ' Loadcore ')); Spl_autoload_register (Array (' Application ', ' loadaction ')); The system will determine whether the currently supplied parameter is a function (string) or an array// If it is an array: 1. Find the first parameter of the array, determine the parameter, if the argument is not an object, the system will think that the string is a class name, so in the patchwork access, the scope of the use of the parse operator to access the second parameter//application::loadcore (); Spl_autoload_register (Array (' Application ', ' Loadmodel ')); }//5. Open session mechanism private static function setsession () {echo __method__.
"; Open session @session_start (); }//6. Load config file private static function Setconfig () {echo __method__.
"; $GLOBALS [' config '] = include_once conf_dir. '/config.php '; }//7. The URL initializes the private static function SetUrl () {echo __method__.
"; Gets the URL information of the user (data submitted by Get method)//module: The requested module (Controller) $module = isset ($_request[' module ')? $_request[' module ': ' Privilege '; Action: Requested Method $action = Isset ($_request[' action ')? $_request[' action ': ' Login ';
Handles string//1.        Turn all lowercase $module = Strtolower ($module);        $action = Strtolower ($action);    2.                The first letter of the class is capitalized, and the method does not need to $module = Ucfirst ($module);        The obtained data is defined as constants used in subsequent methods using local variables that are not available after define (' MODULE ', $module);    Define (' ACTION ', $action);    }//8. Permission validation private static function Setprivilege () {echo __method__.
"; The method of releasing some controllers that do not need to be validated if (! ( MODULE = = ' Privilege ' && (ACTION = = ' Login ' | | ACTION = = ' Signin ' | | ACTION = = ' Captcha ')) {//Both are required to verify if (!isset ($_session[' user ')) {//user not logged in Header (' Location:index.php '); }}}//9. Distribute the private static function Setdispatch () {echo __method__; Find the corresponding controller class, instantiate, and then call the corresponding method $module = module. ' Action '; Get the controller name $module = new $module (); Create a Controller object $action = action; $module $action (); Call a method in the controller}
    //初始化方法    public static function run(){        //初始化项目        //1.初始化字符集        self::setHeader();        //2.初始化系统常量        self::setConst();        //3.错误信息        self::setErrors();        //4.自动加载        self::setAutoload();        //5.session开启        self::setSession();        //6.配置文件        self::setConfig();        //7.URL初始化        self::setUrl();        //8.权限验证        self::setPrivilege();        //9.分发        self::setDispatch();    }}

indexphp

//定义一个常量,用于其他文件的判断//入口文件常量define('ACCESS','ACC');//加载初始化类Application.class.phpinclude_once 'Core/Application.class.php';//调用系统初始化方法//调用Application类的静态方法Application::run();

Reply content:

PrivilegeAction.class.php

Determining whether a constant is defined, if not defined, means that it is not the requested INDEX.PHPIF (!defined (' ACCESS ')) exit;//initializes class application{//1. Initialize the character set private static function SetHeader () {echo __method__.
"; Header (' Content-type:text/html;charset=utf-8 '); }//2. Initialize the system constants private static function Setconst () {echo __method__.
"; Set the root directory constant define (' Root_dir ', str_replace ('/core ', ' ', str_replace (' \ \ ', '/', __dir__))); Define other directories define (' Core_dir ', Root_dir. '/core '); Define (' Action_dir ', Root_dir. '/action '); Define (' Conf_dir ', Root_dir. '/conf '); Define (' Model_dir ', Root_dir. '/model '); Define (' View_dir ', Root_dir. '/view '); Define (' Pub_dir ', Root_dir. '/public '); }//3. Error message private static function seterrors () {echo __method__.
"; Development environment, display errors, display all levels of error//production environment, do not display errors, hide all levels of error (System to do fault-tolerant processing) @ini_set (' error_reporting ', 1); @ini_set (' display_errors ', 1); }//4. Auto Load//4.1 Load Controller class public static function Loadaction ($class) {echo __method__.
"; Determine if (Is_file (Action_dir). "/$class. class.php")) {include_once action_dir. "/$class. class.php"; }}//4.2 loads the core class public static function Loadcore ($class) {echo __method__.
"; Determine if (Is_file (Core_dir). "/$class. class.php")) {include_once core_dir. "/$class. class.php"; }}//4.3 loads the model class public static function Loadmodel ($class) {echo __method__.
"; Determine if (Is_file (Model_dir). "/$class. class.php")) {include_once model_dir. "/$class. class.php"; }}//Register all automatic loading methods in the auto-loading mechanism private static function setautoload () {echo __method__.
"; Spl_autoload_register (Array (' Application ', ' Loadcore ')); Spl_autoload_register (Array (' Application ', ' loadaction ')); The system will determine whether the currently supplied parameter is a function (string) or an array// If it is an array: 1. Find the first parameter of the array, determine the parameter, if the argument is not an object, the system will think that the string is a class name, so in the patchwork access, the scope of the use of the parse operator to access the second parameter//application::loadcore (); Spl_autoload_register (Array (' Application ', ' Loadmodel ')); }//5. Open session mechanism private static function setsession () {echo __method__.
"; Open session @session_start (); }//6. Load config file private static function Setconfig () {echo __method__.
"; $GLOBALS [' config '] = include_once conf_dir. '/config.php '; }//7. The URL initializes the private static function SetUrl () {echo __method__.
"; Gets the URL information of the user (data submitted by Get method)//module: The requested module (Controller) $module = isset ($_request[' module ')? $_request[' module ': ' Privilege '; Action: Requested Method $action = Isset ($_request[' action ')? $_request[' action ': ' Login ';
Handles string//1.        Turn all lowercase $module = Strtolower ($module);        $action = Strtolower ($action);    2.                The first letter of the class is capitalized, and the method does not need to $module = Ucfirst ($module);        The obtained data is defined as constants used in subsequent methods using local variables that are not available after define (' MODULE ', $module);    Define (' ACTION ', $action);    }//8. Permission validation private static function Setprivilege () {echo __method__.
"; The method of releasing some controllers that do not need to be validated if (! ( MODULE = = ' Privilege ' && (ACTION = = ' Login ' | | ACTION = = ' Signin ' | | ACTION = = ' Captcha ')) {//Both are required to verify if (!isset ($_session[' user ')) {//user not logged in Header (' Location:index.php '); }}}//9. Distribute the private static function Setdispatch () {echo __method__; Find the corresponding controller class, instantiate, and then call the corresponding method $module = module. ' Action '; Get the controller name $module = new $module (); Create a Controller object $action = action; $module $action (); Call a method in the controller}
    //初始化方法    public static function run(){        //初始化项目        //1.初始化字符集        self::setHeader();        //2.初始化系统常量        self::setConst();        //3.错误信息        self::setErrors();        //4.自动加载        self::setAutoload();        //5.session开启        self::setSession();        //6.配置文件        self::setConfig();        //7.URL初始化        self::setUrl();        //8.权限验证        self::setPrivilege();        //9.分发        self::setDispatch();    }}

indexphp

//定义一个常量,用于其他文件的判断//入口文件常量define('ACCESS','ACC');//加载初始化类Application.class.phpinclude_once 'Core/Application.class.php';//调用系统初始化方法//调用Application类的静态方法Application::run();

It should not setUrl have been running, but setConfig it would have hung up in the past.
Watch setConfig the check.$GLOBALS['config'] = include_once CONF_DIR . '/config.php';
See config.php If the content is correct.

The configuration file is wrong

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.