Codeigniter. php loads a lot of external files and completes a complete CI process! & Amp; nbsp; & amp; lt ;? Php/*** reprinted please keep the link * @ linkhttp: // www. php
Codeigniter. php loads a lot of external files and completes a complete CI process!
$ Assign_to_config ['subclass _ prefix']);}/** the default value of php program running is 30 s, which is extended by set_time_limt. for details about set_time_Limit () http://www.phpddt.com/php/set_time_limit.html * Extended reading, about safe_mode: http://www.phpddt.com/php/643.html , You will fully understand */if (function_exists ("set_time_limit") = true and @ ini_get ("safe_mode") = 0) {@ set_time_limit (300 );} /** load the Benchmark, which is very simple. it is to calculate the running time of the program between any two points */$ BM = & load_class ('benchmark', 'core '); $ BM-> mark ('total _ execution_time_start '); $ BM-> mark ('loading _ time: _ base_classes_start'); // load the hook, which will be analyzed later, this is really good. it can be expanded to change the CI running process $ EXT = & load_class ('hooks', 'core'); // Here is a hook, in fact, this hook program runs $ EXT-> _ call_hook ('pre _ system') here; // loads the configuration file, here are some functions for loading or obtaining configuration information $ CFG = & load_class ('config', 'core'); // if the function is in index. $ assign_to_config is also configured in php, and is added to $ CFGif (isset ($ assign_to_config) {$ CFG-> _ assign_to_config ($ assign_to_config );} // load the utf8 component, URI component, and Router component $ UNI = & load_class ('utf8', 'core'); $ URI = & load_class ('URL ', 'core'); $ RTR = & load_class ('router ', 'core'); $ RTR-> _ set_routing (); // if it is in index. if $ routing is defined in php, It overwrites the preceding route if (isset ($ routing) {$ RTR-> _ set_overrides ($ routing );} // Load the output component. Otherwise, how do you use $ this-> Load-> view ()? $ OUT = & load_class ('output', 'core '); // see the hook again. here you can write the hook program to replace the cache Output of the Output class. if ($ EXT-> _ call_hook ('cache _ override') = FALSE) {if ($ OUT-> _ display_cache ($ CFG, $ URI) = TRUE) {exit ;}// security component, anti-xss attack, csrf attack // xss attack: http://www.phpddt.com/php/php-prevent-xss.html // About csrf: attack: http://www.phpddt.com/reprint/csrf.html $ SEC = & load_class ('security', 'core'); // load the input component, which is your commonly used $ this-> input-> post (); $ IN = & load_class ('input', 'core'); // load the language component $ LANG = & load_class ('Lang ', 'core '); // introduce the controller parent class require BASEPATH of CI. 'core/Controller. php '; function & get_instance () {return CI_Controller: get_instance () ;}// if (file_exists (APPPATH. 'core /'. $ CFG-> config ['subclass _ prefix']. 'controller. php ') {require APPPA TH. 'core /'. $ CFG-> config ['subclass _ prefix']. 'controller. php ';} // load the Controller in your own application. if there is no such error, if (! File_exists (APPPATH. 'controllers /'. $ RTR-> fetch_directory (). $ RTR-> fetch_class (). '. php ') {show_error ('unable to load your default controller. please make sure the controller specified in your Routes. php file is valid. ');} include (APPPATH. 'controllers /'. $ RTR-> fetch_directory (). $ RTR-> fetch_class (). '. php '); // all the basic classes are loaded. mark $ BM-> mark ('loading _ time: _ base_classes_end '); // The route obtains the controller name and method name. for example, the default value is welcome. /Index $ class = $ RTR-> fetch_class (); $ method = $ RTR-> fetch_method (); // here CI specifies that non-public methods generally start, the following is a judgment. if the URI is inaccessible, show_404 () if (! Class_exists ($ class) OR strncmp ($ method, '_', 1) = 0OR in_array (strtolower ($ method), array_map ('strtolower ', get_class_methods ('ci _ controller') {if (! Empty ($ RTR-> routes ['1970 _ override']) {$ x = explode ('/', $ RTR-> routes ['1970 _ override']); $ class = $ x [0]; $ method = (isset ($ x [1])? $ X [1]: 'index'); if (! Class_exists ($ class) {if (! File_exists (APPPATH. 'controllers /'. $ class. '. php ') {show_404 ("{$ class}/{$ method}");} include_once (APPPATH. 'controllers /'. $ class. '. php ') ;}} else {show_404 ("{$ class}/{$ method}") ;}// it's a hook, this hook occurs before the controller is instantiated $ EXT-> _ call_hook ('pre _ controller '); // mark another point $ BM-> mark ('Controller _ execution_time _('. $ class. '/'. $ method. ') _ start'); // The controller is finally instantiated $ CI = new $ class (); // hook. I don't want to say more about $ EXT-> _ call_hook ('post _ controller_constru Ctor ');/** invoke * Call the requested method * -------------------------------------------------------- * // Is there a "remap" function? If so, we call it insteadif (method_exists ($ CI, '_ remap') {$ CI-> _ remap ($ method, array_slice ($ URI-> rsegments, 2);} else {// is_callable () returns TRUE on some versions of PHP 5 for private and protected // methods, so we'll use this workaround for consistent behaviorif (! In_array (strtolower ($ method), array_map ('strtolower ', get_class_methods ($ CI) {// Check and see if we are using a 404 override and use it. if (! Empty ($ RTR-> routes ['1970 _ override']) {$ x = explode ('/', $ RTR-> routes ['1970 _ override']); $ class = $ x [0]; $ method = (isset ($ x [1])? $ X [1]: 'index'); if (! Class_exists ($ class) {if (! File_exists (APPPATH. 'controllers /'. $ class. '. php ') {show_404 ("{$ class}/{$ method}");} include_once (APPPATH. 'controllers /'. $ class. '. php '); unset ($ CI); $ CI = new $ class () ;}} else {show_404 ("{$ class}/{$ method }");}} // Finally, the method is called. $ this-> load-> view () puts the content in the cache call_user_func_array (array (& $ CI, $ method ), array_slice ($ URI-> rsegments, 2);} $ BM-> mark ('Controller _ execution_time _('. $ class. '/'. $ method. ') _ end'); $ EXT-> _ call_hook ('post _ controller '); // Here, the content in the cache area is output if ($ EXT-> _ call_hook ('display _ override') = FALSE) {$ OUT-> _ display () ;}$ EXT-> _ call_hook ('post _ system '); // close the database link if (class_exists ('ci _ db') AND isset ($ CI-> DB) {$ CI-> db-> close ();}