PHP Single Entry Request

Source: Internet
Author: User
Tags constant definition


<?phprequire_once ' config.php '; require_once db_dir. ' db.php ';//Database object $db = new MySQL ();/** * Single-entry dispatcher processing *///whether to login//if ($_get[' action ']! = ' Login ') {//    if (Empty ($_ses sion[' user ']) {//        return 0;//    }//} $controller =!empty ($_get[' controller '])? $_get[' Controller ']: ' index.php '; $dir = Classes_dir. ‘/‘ . $controller. ‘/‘ . $controller. '. php ', if (Is_file ($dir) &&!empty ($_get[' controller ')) {    include_once $dir;    $obj = new $_get[' controller '] ();    $action = $_get[' action '];    if (!empty ($action)) {        echo $obj, $action ();    }    Clear Object    unset ($obj);} else {    //not logged in or request error    echo 0;} $DB->closeconnection ();


<?phperror_reporting (E_error); Session_Start (); Open Sessiondate_default_timezone_set (' Asia/shanghai '); Time zone Setting/** * file address constant definition */define (' Base_dir ', DirName (__file__)); root directory define (' Classes_dir ', Base_dir. '/classes/'); CLASSES directory define (' Db_dir ', Classes_dir. ' db/'); Database object Directory define (' Test_dir ', Classes_dir. ' test/'); PHP Test Class 

PHP Single Entry Request

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: 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.