autoload.php
<? PHP function framework_autoload ($className) { $className=str_replace (' \ \ ', '/',$className) ; include_once ($className. '. Class '. '. php ');} Spl_autoload_register (' framework_autoload ');
init.php
<?PHPrequire_once($_server[' Document_root ']. "/comm.php");//Open Debug mode suggest the development phase to open the deployment phase comment or set to FalseDefine(' App_debug ',true); App_debug?error_reporting(E_all):error_reporting(0);//defining the App catalogDefine(' App_path ',$_server[' Document_root ']. "/new_framework/");//define an include start path that is automatically loaded by class name$autoLoadIncludePath=Array(App_path);Set_include_path(Get_include_path() . Path_separator.implode(Path_separator,$autoLoadIncludePath));//PHP Automatic loadingrequire_once(App_path. " Bll/autoload.php ");//MVC processing$c=$_request[' C '];$controller= ' controller\\ '.$c.‘ Controller ';$action=$_request[' A '];if(!class_exists($controller)){ $res[' Code ']=1000; $res[' Msg ']=$c.‘ Controller does not exist! ‘;}Else if(!method_exists($controller,$action)){ $res[' Code ']=1001; $res[' Msg ']=$action.‘ method does not exist! ';}Else{ $CONTROLLEROBJ=New $controller(); $res=$CONTROLLEROBJ-$action();}EchoJson_encode ($res);
PHP auto_load MVC Interface Framework