(E) Thinkphp common function uses short introduction -TTLSA

This chapter focuses About thinkphp framework built-use functions, and how to call a custom function Note: The specific use is not in this chapter too much to explain, if you are interested you can check out the official website tutorials 1, D Reference Links: Thinkphp D method Detailed D method should be used in a relatively large number of methods, for example of a custom model class, ThinkPHP frame is an encapsulation of the model class is instantiated, and to achieve a single-mode embodiment, and supports cross-project packet call, the call in the following format: D ( '[project: //] [packets /] model', 'model layer name') return value is an instance of the model object. 2, Link Reference M: Thinkphp Detailed Method M M A method for distinguishing a basic model to instantiate classes, methods, and D are: 1, no custom model class, IO load reduction, better performance; 2, instantiation after only call base model class (class default model) method; 3, link information may specify the prefix table, database, and the database in the instantiation; D method is powerful custom models embodied in your class package how strong, but with the new version of the base model classes ThinkPHP framework of the more powerful, M method is also more practical than the D method. Method call format M: M ( '[base model name:] model name', 'table prefix', 'connection information database') 3, G Reference links: Thinkphp Method G Detailed ThinkPHP long felt need by debug_start, debug_end even the Debug class method to complete the function, version 3.1 is a simple method to replace the G, can not ignore that is a gorgeous upgrade. The method comprises the role of G mark position and interval statistics two functions, G statistical method may use the execution time and memory 4, L Reference links: Thinkphp Detailed Method L A method for the case where L multilingual enabled, setting and getting the current language definition. Call format: L ( 'linguistic variables' [, 'linguistic']). 5, reference links Method C: Thinkphp C Detailed Method C is a method for setting ThinkPHP, acquire, and save the configuration parameters, the use of higher frequencies. Learn C under ThinkPHP methods need to first understand the configuration, as are all the operations related to the configuration around C methods. ThinkPHP configuration file using PHP array definition format. 6, A method reference links: Thinkphp Detailed Method A A method for instantiating a controller inside, call format: A ( '[Project: //] [packets /] module', 'layer controller name') 7, reference links R: Thinkphp Detailed method R R methods for invoking the operation of a controller, to further enhance and complement a method. R method invocation format: R ( '[Project: //] [packets] / module / operation', 'with', 'layer controller name'). 8, reference links Method U: Thinkphp Detailed Method U U a method for completing the assembly of the URL address, characterized by automatically according to the current URL and arranged to generate a corresponding URL address, the format: U ( 'address',' with ',' pseudo-static ',' jump if ',' display domain name '); the benefits of using U method in a template rather than a fixed-coded URL address is that once you change the environment or change parameters, you do not need to change any code in the template. Call format template need {: U ( 'address', 'parameter' ...)} manner as 9, I Reference links: Thinkphp Detailed methods the I The method I ThinkPHP new version is 3.1.3 As you can see, like, I ThinkPHP single-letter method is one of many functions of the new members, whose name comes from the English Input (input), mainly for easier and safer the input acquisition system variables, can be used anywhere, use the following format: I ( '. variable type variable name', [ 'default'], [ 'filtration']) refers to a variable type manner or a request input type, comprising: variable type meaning get a GET parameter post acquisition POST parameter param automatically determine the type of request acquires GET, POST or PUT request parameter acquisition parameter rEQUEST put obtain PUT parameter session obtains $ _SESSION parameter cookie acquired $ _COOKIE parameter server acquires $ _SERVER parameter globals Get $ GLOBALS parameter Note: The variable type is not case-sensitive. Variable names are strictly case-sensitive. Default filtering methods and optional parameters belong. 10, S Reference Links: Thinkphp S method Detailed file cache, long life, time after expiration of the cached content will be updated. Commonly used in the single-page data cache. S supports caching method is valid, in many cases, we may not need the concept validity, or use a cache of papers will be able to meet the requirements, the system also provides a quick method F for file caching method specifically the way. F method can only be used for caching simple data types, and does not support the validity of cached objects 11, F Reference Links: Thinkphp F Detailed Method We know how the S method in ThinkPHP, F method is actually a subset of the functionality of the S method, used only for simple data cache, and can only support the file format is not supported cache is valid, because the use of PHP return way , so its efficiency is higher than the S method, so we call it fast caching method. Features F method are: simple data cache; file format to save; return data using PHP way to load the cache; cache and support subdirectories are automatically created; delete cache and supports batch delete; 12, N Reference Links: Thinkphp N Detailed Method N Method belong counter method, the query is used for the core, cache statistics and the statistics count. But in fact can be used for counting purposes other applications, the use of relatively simple, call format: N ( 'counter position' [, 'step value'])

Reproduced in: https: //my.oschina.net/766/blog/211242

Guess you like

Origin blog.csdn.net/weixin_33795833/article/details/91546597