ThinkPHP single letter function (Quick Method) usage summary, thinkphp Function
ThinkPHP has many easy-to-use single-letter functions (that is, quick methods), which can be easily called by developers, but the letter functions are not easy to remember. This article will summarize all the letter functions, to facilitate future search.
1. U () URL Assembly supports different URL Modes
U($url='',$vars='',$suffix=true,$domain=false)
@ Param string $ url URL expression. Format: '[module/controller/Operation # anchor @ domain name]? Parameter 1 = value 1 & Parameter 2 = value 2 ...'
@ Param string | array $ vars input parameters, which support arrays and strings
@ Param string $ suffix: pseudo-static suffix. The default value is true, indicating that the configuration value is obtained.
@ Param boolean $ whether the domain name is displayed
@ Return string
2. D () D function is used to instantiate the model class format [Resource: //] [module/] Model
D($name='',$layer='')
@ Param string $ name: Resource address
@ Param string $ layer model layer name
@ Return Model
3. The M () M function is used to instantiate a Model without a Model file.
M($name='',$tablePrefix='',$connection='')
@ Param string $ name the Model name supports specifying the basic Model, for example, role Model: User
@ Param string $ tablePrefix table prefix
@ Param mixed $ connection database connection information
@ Return Model
4. I () supports filtering input parameters and default values.
I($name,$default='',$filter=null)
Usage:
I ('id', 0); // get the id parameter to automatically judge get or post I ('Post. name', '', 'htmlspecialchars'); // get $ _ POST ['name'] I ('get. '); // GET $ _ GET
5. B () executes a behavior
B($name,$tag='',&$params=NULL)
@ Param string $ name behavior name
@ Param string $ tag Name (the behavior class does not need to be passed in)
@ Param Mixed $ parameters passed in by params
@ Return void
6. C () read and set configuration parameters
C($name=null,$value=null,$default=null)
@ Param string | array $ name configuration variable
@ Param mixed $ value configuration value
@ Param mixed $ default Value
@ Return mixed
7. E () Throw Exception Handling
E($msg, $code=0)
@ Param string $ msg exception message
@ Param integer $ the default code for code exceptions is 0.
@ Return void
8.G () record and statistical time (microseconds) and memory usage
G($start,$end='',$dec=4)
Usage:
G ('begin'); // record start Mark bit //... interval run code G ('end'); // record end tag echo G ('begin', 'end', 6 ); // The running time of the statistical interval is accurate to the last 6 digits of the decimal number echo G ('begin', 'end', 'M'); // The memory usage of the statistical interval.
If the end tag is not defined, the current tag is automatically used as the tag.
The MEMORY_LIMIT_ON constant must be set to true for memory usage statistics.
@ Param string $ start tag
@ Param string $ end tag
@ Param integer | string $ dec decimal point or m
@ Return mixed
9. L () Get and set language definitions (Case Insensitive)
L($name=null,$value=null)
@ Param string | array $ name language variable
@ Param mixed $ value language value or variable
@ Return mixed
10. T () Get Template File Format resources: // module @ topic/controller/Operation
T($template='',$layer='')
@ Param string $ name: template resource address
@ Param string $ layer view layer (directory) Name
@ Return string
11. N () set and obtain statistics
N($key,$step=0,$save=false)
Usage:
N ('db', 1); // record database operation count N ('read', 1); // record read count echo N ('db '); // obtain the number of database operations on the current page echo N ('read'); // obtain the number of reads on the current page
@ Param string $ key ID location
@ Param integer $ step value
@ Return mixed
12. function A () A is used to instantiate the controller.
Format: [Resource: //] [module/] Controller
A($name,$layer='',$level='')
@ Param string $ name: Resource address
@ Param string $ layer control layer name
@ Param integer $ level controller level
@ Return Controller | false
13. R () Remote Call of the controller Operation Method
URL parameter format [Resource: //] [module/] Controller/Operation
R($url,$vars=array(),$layer='')
@ Param string $ url call address
@ Param string | array $ vars call parameters support strings and Arrays
@ Param string $ name of the control layer to be called by the layer
@ Return mixed
14. W () Rendering output Widget
W($name,$data=array())
@ Param string $ name Widget name
@ Param array $ parameters passed in by data
@ Return void
15. S () Cache Management
S($name,$value='',$options=null)
@ Param mixed $ name indicates the cache name. If it is an array, cache settings are performed.
@ Param mixed $ value cache value
@ Param mixed $ options cache Parameters
@ Return mixed
16. F () Fast File Data Reading and storageFor simple data strings and Arrays
F($name, $value='',$path=DATA_PATH)
@ Param string $ name cache name
@ Param mixed $ value cache value
@ Param string $ path: cache path
@ Return mixed
For detailed operations on these shortcuts, you can refer to the related instance tutorials on this site.
How to Use Quick method N in thinkphp
ThinkPHP defines shortcuts for some common operations. These methods are named by a single letter and are easy to remember. It is very interesting that the letters of these shortcuts contain ADSL letters. Therefore, we call them the ADSL method, but they are not limited to the following four methods:
A. Quick instantiation of Action class library
B. execution behavior
C. Configure the parameter access method
D. Quickly instantiate the Model class library.
F quick and simple text data access method
L language parameter access method
M fast high-performance instantiation Model
R: quickly and remotely call Action Methods
S quick cache access method
Dynamic generation and redirection of U URLs
W. Quick Widget Output Method
It can be seen from the above that the name of the shortcut method is generally based on the first letter of an English word corresponding to the method that matches its functional meaning, as to the detailed use of each Shortcut method, we will provide specific descriptions in specific chapters or refer to the appendix section. Thank you for choosing
How to Use PHP functions for thinkphp templates
That's what I wrote. Yes. {$ Create_time | date = 'Y-m-d H: I: s', ###}, but $ create_time should be an 11-digit number.
Reference: doc.thinkphp.cn/manual/use_function.html