PHP auto_load MVC Interface Framework

Source: Internet
Author: User

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

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.