Read the source code of the CI framework-Lang. php

Source: Internet
Author: User
CI framework source code reading --------- Lang. php & lt ;? Phpif (! Defined (BASEPATH) exit (Nodirectscriptaccessallowed); *** CodeIgniter *** Anopensourceapplicationdevelopmentframeworkfor CI framework source code reading --------- Lang. php
 In is_loaded and $ this-> language, go to * @ param booladd suffix to $ langfile to check whether the suffix * @ param stringalternative path to look for language file. the custom path of the language pack * @ returnmixed */function load ($ langfile = '', $ idiom = '', $ return = FALSE, $ add_suffix = TRUE, $ alt_path ='') {// langfile. remove the php suffix $ langfile = str_replace ('. php ', '', $ langfile); // You do not need to add a suffix if you need it. // Set _ lang. remove and add _ langif ($ add_suffix = TRUE) after langfile) {$ Langfile = str_replace ('_ lang. ', '', $ langfile ). '_ lang';} // add a name for langfile. php suffix $ langfile. = '. php '; // Determine whether the current file has been loaded if (in_array ($ langfile, $ this-> is_loaded, TRUE) {return ;} // Get the data in the configuration file $ config = & get_config (); // if the language to be used is null // we will obtain if ($ idiom = '') {$ deft_lang = (! Isset ($ config ['language'])? 'INC': $ config ['language']; $ idiom = ($ deft_lang = '')? 'INC': $ deft_lang;} // Determine where the language file is and load it // find the language pack in the custom path and load if ($ alt_path! = ''& File_exists ($ alt_path. 'language /'. $ idiom. '/'. $ langfile) {include ($ alt_path. 'language /'. $ idiom. '/'. $ langfile);} else {// call get_instance ()-> load-> get_package_paths (TRUE) if the custom path is not found) // search for/get_package_paths in the package path. in php, $ found = FALSE; foreach (get_instance ()-> load-> get_package_paths (TRUE) as $ package_path) {if (file_exists ($ package_path. 'language /'. $ idiom. '/'. $ langfile) {include ($ package_p Ath. 'language /'. $ idiom. '/'. $ langfile); $ found = TRUE; break;} // if not found, only an error is returned. // if ($ found! = TRUE) {show_error ('unable to load the requested language file: language/'. $ idiom.'/'. $ langfile) ;}} if (! Isset ($ lang) {log_message ('error', 'Language file contains no data: Language /'. $ idiom. '/'. $ langfile); return;} if ($ return = TRUE) {return $ lang;} $ this-> is_loaded [] = $ langfile; $ this-> language = array_merge ($ this-> language, $ lang); unset ($ lang); log_message ('debug', 'Language file loaded: Language /'. $ idiom. '/'. $ langfile); return TRUE;} // --------------------------------/*** Fetch a single line of text From the language array * get a line of text * @ accesspublic * @ paramstring $ linethe language line * @ returnstring */function line ($ line = '') {/** $ this-> language format * $ lang ['error _ email_missing '] = "You must submit an email address "; * $ lang ['error _ url_missing '] = "You must submit a URL"; * $ lang ['error _ username_missing'] = "You must submit a username "; */$ value = ($ line = ''OR! Isset ($ this-> language [$ line])? FALSE: $ this-> language [$ line]; // Because killer robots like unicorns! If ($ value = FALSE) {log_message ('error', 'could not find the language line "'. $ line. '"') ;}return $ value ;}// END Language Class/* End of file Lang. php * // * Location :. /system/core/Lang. 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.