My interface Framework---framework function file common.php

Source: Internet
Author: User
Tags get ip

<?phpdefined(' Jdhu ') OR die(' No Allow access ');/** * Load config file*/function&get_config ($replace=Array()){    Static $config; if(Empty($config)) {        $file _path= APPPATH. ' Config/config.php '; //If no formal configuration exists, load the environment configuration        if(!file_exists($file _path)) {            $file _path= APPPATH. ' config/'. Environment. ' Config.php '; }        require($file _path); }    //in the replacement configuration file    foreach($replace  as $key=$value) {        $config[$key] =$value; }    return $config;}/** * Load frame/Application class library*/function&load_class ($class,$directory= ' Libraries ',$param=NULL){    Static $_classes=Array(); //if the class has been loaded, the return class    if(isset($_classes[$class])) {        return $_classes[$class]; }    $name=FALSE; //introduce the core class//Find the application first, second find the framework//Overlay Framework class file: If the Jdhu class exists for the application, the framework class is not introduced    foreach(Array(APPPATH, Jdhu) as $path) {        if(file_exists($path.$directory.‘ /‘.$class.‘. Php)) {            //Core class name            $name= ' jdhu_ '.$class; //Note: class_exists The second parameter defaults to True, calling the __autoload () function            if(class_exists($name,FALSE) ===FALSE) {                require_once($path.$directory.‘ /‘.$class.‘. Php); }             Break; }    }    //Introducing inheriting classes: Inheriting framework classes or overriding classes    if(file_exists(APPPATH.$directory.‘ /'. Config_item (' Subclass_prefix ').$class.‘. Php)) {        //Inheriting class names        $name= Config_item (' Subclass_prefix ').$class; require_once(APPPATH.$directory.‘ /‘.$name.‘. Php); }    //gets the class that is loaded, the record has been loadedIs_loaded ($class); //If there are parameters, the class with parameter initialization    $_classes[$class] =isset($param) ?New $name($param) :New $name(); return $_classes[$class];}/** * Get Configuration Items*/functionConfig_item ($item){    Static $_config; if(Empty($_config)) {                //A reference cannot be assigned directly to a static variable and can be assigned to a static variable array        $_config[0] =&Get_config (); }    return $_config[0] [$item];}/** * Gets the class that is loaded, if there is a class name, the record has been loaded*/function&is_loaded ($class= ' '){    Static $_is_loaded=Array(); if($class) {        //class name        $_is_loaded[Strtolower($class)] =$class; }    return $_is_loaded;}/** * Output JSON error and exit*/functionDie_error ($message){    Static $_response; if($_response===NULL) {        $_response[0] =& load_class (' Response ', ' core '); } log_message (' Error ',$message); $_response[0]->die_error ($message);}/** * Record log*/functionLog_message ($level,$message){    Static $_log; if($_log===NULL) {        $_log[0] =& load_class (' Log ', ' core '); }    $_log[0]->write_log ($level,$message);}/** * Get IP address*/functionip_address () {Static $_ip_address= ' '; if($_ip_address) {        return $_ip_address; }    $_ip_address=$_server(' REMOTE_ADDR '); return $_ip_address;}/** * Note: function &xxx () returns the pointer address of the result*/?>

My interface Framework---framework function file common.php

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.