: This article mainly introduces ThinkPHP built-in functions D, F, S, C, L, A, and I. If you are interested in PHP tutorials, refer. Single letter functions D, F, S, C, L, A, and I are all defined in ThinkPHP/Mode/Api/functions. php.
The following describes their functions:
D () load Model class
M () load Model class
A () load Action Class
L () obtain language definitions
C () get configuration value usage is C ("The subscript entered in the array in the configuration file ")
S () global cache configuration usage S ("This is a unique identifier ")
F () fast file data reading and saving for simple types of data strings, arrays
I () quickly create an object instance
Attached here: prototype definitions of all built-in functions of ThinkPHP
1
36 * G ('begin'); // record start flag 37 *//... run the code 38 * G ('end') in the interval. // record the ending tag with 39 * echo G ('BEGIN', 'End', 6 ); // The running time of the statistical interval is precise to the last 6 digits of the decimal number 40 * echo G ('BEGIN', 'End', 'M '); // memory usage in the statistical interval 41 * if the end flag is not defined, the current flag will be used as the flag 42 * where the statistical memory usage requires the MEMORY_LIMIT_ON constant to be true to be valid 43 *44 * @ param string $ start tag 45 * @ param string $ end tag 46 * @ param integer | string $ dec decimal point or m 47 * @ return mixed 48 */49 function G ($ start, $ end = '', $ dec = 4) {} 50 51/** 52 * get and set language definitions (case insensitive) 53 * @ param string | array $ name language variable 54 * @ param string $ value language value 55 * @ return mixed 56 */57 function L ($ name = null, $ value = null) {} 58 59/** 60 * add and retrieve page Trace records 61 * @ param string $ value variable 62 * @ param string $ label tag 63 * @ param string $ level log level 64 * @ param boolean $ whether record records logs 65 * @ return void 66 */67 function trace ($ value = '[think]', $ label = '', $ level = 'debug', $ record = false) {} 68 69/** 70 * compiled file 71 * @ param string $ filename File Name 72 * @ return string 73 */74 function compile ($ filename) {} 75 76/** 77 * input parameters can be filtered and the default value is 78 * usage: 79 *80 * I ('id', 0); get the id parameter to automatically judge get or post 81 * I ('post. name ', '', 'htmlspecialchars'); get $ _ POST ['name'] 82 * I ('Get. '); GET $ _ GET 83 *
84 * @ param string $ the name of the name variable supports the specified Type 85 * @ param mixed $ default when the default value does not exist, the default value is 86 * @ param mixed $ filter parameter filtering method 87 * @ return mixed 88 */89 function I ($ name, $ default = '', $ filter = null) {} 90 91/** 92 * set and obtain statistics 93 * usage: 94 *95 * N ('DB', 1); // records database operations 96 * N ('read', 1 ); // record read Times 97 * echo N ('DB'); // Obtain all operations of the database on the current page 98 * echo N ('read '); // Obtain 99 times of reading the current page *
100 * @ param string $ key ID location 101 * @ param integer $ step value 102 * @ return mixed 103 */104 function N ($ key, $ step = 0, $ save = false) {} 105 106/** 107 * string naming style conversion 108 * type 0 convert Java style to C style 1 convert C style to Java style 109 * @ param string $ name string 110 * @ param integer $ type conversion type 111 * @ return string 112 */113 function parse_name ($ name, $ type = 0) {} 114 115/** 116 * optimized require_once 117 * @ param string $ filename File address 118 * @ return boolean 119 */120 function require_cache ($ filename) {} 121 122/** 123 * case sensitive file existence judgment 124 * @ param string $ filename File address 125 * @ return boolean 126 */127 function file_exists_case ($ filename) {} 128 129/** 130 * the class library required for importing is the same as the java Import function. this function has the cache function of 131 * @ param string $ class Library namespace string 132 * @ param string $ baseUrl starting path 133 * @ param string $ ext: the file name imported by ext is 134 * @ return boolean 135 */136 function import ($ class, $ baseUrl = '', $ ext = EXT) {} 137 138/** 139 * import the function library 140 * load ('@. util. array ') 141 * @ param string $ name function library namespace string 142 * @ param string $ baseUrl Start Path 143 * @ param string $ ext imported file extension 144 * @ return void 145 */146 function load ($ name, $ baseUrl = '', $ ext = '. php ') {} 147 148/** 149 * quickly import the class library files of all third-party frameworks of the third-party Framework class Library to the system's Vendor Directory. the 150 * @ param string $ class Library 151 * @ param string $ baseUrl base directory 152 * @ param string $ ext class library suffix 153 * @ return boolean 154 */155 function vendor ($ class, $ baseUrl = '', $ ext = '. php ') {} 156 157/** 158 * D function is used to instantiate the model class format [resource: //] [module/] Model 159 * @ param string $ name resource address 160 * @ param string $ layer Model layer name 161 * @ return Model 162 */163 function D ($ name = '', $ layer = '') {} 164 165/** 166 * M function is used to instantiate a Model without a Model file 167 * @ param string $ name Model name. you can specify a base Model, for example, using Model: user 168 * @ param string $ tablePrefix table prefix 169 * @ param mixed $ connection database connection information 170 * @ return Model 171 */172 function M ($ name = '', $ tablePrefix = '', $ connection ='') {} 173 174/** 175 * parse the resource address and import the class library file 176 * for example, module/controller addon: // module/behavior 177 * @ param string $ name resource address format: [extension: //] [module/] resource name 178 * @ param string $ layer name 179 * @ return string 180 */181 function parse_res_name ($ name, $ layer, $ level = 1) {} 182 183/** 184 * A function is used to instantiate the controller. format: [resource: //] [module/] controller 185 * @ param string $ name resource address 186 * @ param string $ layer Control layer name 187 * @ param integer $ level controller layer 188 * @ return controller | false 189 */190 function A ($ name, $ layer = '', $ level ='') {} 191 192/** 193 * remote call controller operation method URL parameter format [resource: //] [module/] controller/operation 194 * @ param string $ url call address 195 * @ param string | array $ vars call parameters support strings and arrays 196 * @ param string $ name of the control layer to be called by layer 197 * @ return mixed 198 */199 function R ($ url, $ vars = array (), $ layer = '') {} 200 201/** 202 * execute a behavior 203 * @ param string $ name behavior name 204 * @ param Mixed $ params input parameter 205 * @ return void 206 */207 function B ($ name, & $ params = NULL) {} 208 209/** 210 * removed blank spaces and comments in the code 211 * @ param string $ content code content 212 * @ return string 213 */214 function strip_whitespace ($ content) {} 215 216/** 217 * browser-friendly variable output 218 * @ param mixed $ var variable 219 * @ param boolean $ echo whether the output is True by default. if it is false, the output is returned. string 220 * @ param string $ label is empty by default. 221 * @ param boolean $ strict whether strict or not the default value is true 222 * @ return void | string 223 */224 function dump ($ var, $ echo = true, $ label = null, $ strict = true) {} 225 226/** 227 * URL redirection 228 * @ param string $ url redirection URL address 229 * @ param integer $ time waiting time (seconds) 230 * @ param string $ prompt information before msg redirection 231 * @ return void 232 */233 function redirect ($ url, $ time = 0, $ msg = '') {} 234 235/** 236 * cache management 237 * @ param mixed $ name cache name, if you set 238 * @ param mixed $ value for the array, the cache value is 239 * @ param mixed $ options. the cache parameter 240 * @ return mixed 241 */242 function S ($ name, $ value = '', $ options = null) {} 243 244/** 245 * Fast file data reading and storage for simple data strings, array 246 * @ param string $ name cache name 247 * @ param mixed $ value cache value 248 * @ param string $ path cache path 249 * @ return mixed 250 */251 function F ($ name, $ value = '', $ path = DATA_PATH) {} 252 253/** 254 * Generate the unique identification number 255 * @ param mixed $ mix variable 256 * @ return string 257 */258 function to_guid_string ($ mix) {} 259 260/** 261 * XML encoding 262 * @ param mixed $ data 263 * @ param string $ root node name 264 * @ param string $ item sub-index node name 265 * @ param string $ attr root node attribute 266 * @ param string $ id attributes of key conversion for a digital index subnode 267 * @ param string $ encoding data encoding 268 *@ return string 269 */270 function xml_encode ($ data, $ root = 'think', $ item = 'ITEM', $ attr = '', $ id = 'id', $ encoding = 'utf-8 ') {} 271 272/** 273 * data XML encoding 274 * @ param mixed $ data 275 * @ param string $ item node name 276 * @ param string $ id attribute name converted from the numeric index key to 277 * @ return string 278 */279 function data_to_xml ($ data, $ item = 'ITEM', $ id = 'id ') {} 280 281/** 282 * session management function 283 * @ param string | array $ name if the session name is an array, the session value is set to 284 * @ param mixed $ value. 285 * @ return mixed 286 */287 function session ($ name, $ value = '') {} 288/** 289 * Cookie setting, obtaining, and deleting 290 * @ param string $ name cookie name 291 * @ param mixed $ value cookie value 292 * @ param mixed $ options cookie parameter 293 * @ return mixed 294 */295 function cookie ($ name, $ value = '', $ option = null) {} 296 297/** 298 * load dynamic extension file 299 * @ return void 300 */301 function load_ext_file ($ path) {} 302/** 303 * get client IP address 304 * @ param integer $ type return type 0 return IP address 1 return IPV4 address number 305 * @ return mixed 306 */307 function get_client_ip ($ type = 0) {} 308 309/** 310 * send HTTP status 311 * @ param integer $ code status code 312 * @ return void 313 */314 function send_http_status ($ code) {} 315 316 // filter the expression 317 function filter_exp (& $ value) {} 318 319 // The case-insensitive in_array implements 320 function in_array_case ($ value, $ array) {}
The above describes the ThinkPHP built-in functions D, F, S, C, L, A, and I, including some content, hope to be helpful to PHP tutorials.