There are many important functions in thinkphp, most of which are single-letter functions that play a significant role in the development experience.
There is a saying is very incisive: concentrated is the essence! This is definitely TP's single letter method of True portrayal, used by you must understand!
In order to make it easy for everyone to learn and master, here is a summary of the thinkphp in the classic function usage, whether you are senior or rookie tper, you must not miss Oh ^_^
A function: Instantiating A Controller
R function: How to call the controller directly
C functions: Setting and getting configuration parameters
L functions: Setting and getting language variables
D function: Instantiating a model
M function: Instantiate the model (no model classes are defined)
N Function: Counter
G function: Debug statistics
U function: URL address generation
I function: Secure access to system input variables
S function: Cache Settings and Access
F function: Fast Cache settings and access
Session Function: Session operation
Cookie function: Cookie manipulation
Import function: Class Library imports
A function: Used to instantiate the action format: [Project://][Group/] Module
- /**
- * The a function is used to instantiate the action format: [Project://][Group/] module
- * @param string $name action Resource address
- * @param string $layer Control layer name
- * @param boolean $common Whether public directory
- * @return action|false
- */
-
- a ( $name , $layer = ", $common =
Copy Code
b function: Perform a behavior
- /**
- * Perform an action
- * @param string $name behavior name
- * @param Mixed $params parameters passed in
- * @return void
- */
- B($name, &$params=NULL)
Copy Code
C function: Get and Set configuration parameters support Batch Definition
- /**
- * Get and Set configuration parameters support Batch Definition
- * @param string|array $name Configuration variables
- * @param mixed $value configuration values
- * @return Mixed
- */
- C($name=null, $value=null)
Copy Code
D function: Used to instantiate the model format item://Group/module
- /**
- * The D function is used to instantiate the model format item://Group/module
- * @param string $name model resource Address
- * @param string $layer business layer Name
- * @return Model
- */
- D($name=",$layer=")
Copy Code
F function: Fast file data read and save for simple type data strings, arrays
- /**
- * Fast file data reading and saving for simple type data strings, arrays
- * @param string $name cache name
- * @param mixed $value Cache value
- * @param string $path cache path
- * @return Mixed
- */
- F($name, $value=", $path=data_path)
Copy Code
G Functions: Recording and statistical time (microseconds) and memory usage
- /**
- * Recording and statistical time (microseconds) and memory usage
- * How to use:
- * <code>
- * G (' begin '); Record start tag bit
- * // ... Interval Run code
- * G (' end '); Record end tag Bit
- * Echo G (' Begin ', ' End ', 6); Statistics interval run time is accurate to 6 digits after decimal
- * Echo G (' Begin ', ' End ', ' m '); Statistical interval Memory Usage
- * If the end tag bit is not defined, it will be automatically marked as the current marker bit
- * Where statistics memory usage requires MEMORY_LIMIT_ON constant is true only valid
- * </code>
- * @param string $start start tag
- * @param string $end end tag
- * @param integer|string $dec decimal digits or M
- * @return Mixed
- */
- G($start,$end=",$dec=4)
Copy Code
I function: Get input parameters support filtering and default values
- /**
- * Get input parameters to support filtering and default values
- * How to use:
- * <code>
- * I (' id ', 0); Get ID parameter automatically determine get or post
- * I (' post.name ', ' ', ' htmlspecialchars '); Get $_post[' name ']
- * I (' get. '); Get $_get
- * </code>
- * @param string $name The name of the variable supports the specified type
- * @param the default value when the mixed $default does not exist
- * @param mixed $filter parameter filtering method
- * @return Mixed
- */
- I($name,$default=",$filter=null)
Copy Code
L Functions: Get and set language definitions (case insensitive)
- /**
- * Get and set language definitions (case insensitive)
- * @param string|array $name language variables
- * @param string $value language value
- * @return Mixed
- */
- L($name=null, $value=null)
Copy Code
m function: Used to instantiate a model without a modeling file
- /**
- * The M function is used to instantiate a model without a modeling file
- * @param string $NAME model name supports specifying the underlying model such as Mongomodel:user
- * @param string $tablePrefix table prefix
- * @param mixed $connection database connection information
- * @return Model
- */
- M($name=", $tablePrefix=",$connection=")
Copy Code
n functions: Set up and get statistical data
- /**
- * Set up and get statistical data
- * How to use:
- * <code>
- * N (' db ', 1); Number of database operations logged
- * N (' read ', 1); Record number of reads
- * Echo N (' db '); Get all operations for the current page database
- * Echo N (' read '); Gets the current page read count
- * </code>
- * @param string $key identify the location
- * @param integer $step step value
- * @return Mixed
- */
- N($key, $step=0,$save=false)
Copy Code
R functions: How to invoke modules remotely URL parameter format [project://][Group/] Module/operation
- /**
- * Operation method of Remote Call module URL parameter format [project://][Group/] Module/operation
- * @param string $url call Address
- * @param string|array $vars Call parameters support strings and arrays
- * @param string $layer The name of the control layer to invoke
- * @return Mixed
- */
- R($url,$vars=array(),$layer=")
Copy Code
s function: Cache management
- /**
- * Cache Management
- * @param mixed $name cache name, If the array represents the cache setting
- * @param mixed $value Cache values
- * @param mixed $options Cache parameters
- * @return mixed
- */
-
- s ( $name , $value = ", $options =null) &NBSP;
Copy Code
T function: Get template file Format item://Group @ theme/module/operation
- /**
- * Get template file Format item://Group @ theme/module/operation
- * @param string $name template resource Address
- * @param string $layer view layer (directory) name
- * @return String
- */
- T($template=",$layer=")
Copy Code
u function: URL assembly supports different URL patterns
- /**
- * URL assembly supports different URL patterns
- * @param string $url URL expression, format: ' [group/module/Operation # Anchor @ domain name]? parameter 1= value 1& parameter 2= value 2 ... '
- * @param string|array $vars parameters passed in, supports arrays and strings
- * @param string $suffix pseudo-static suffix, which by default is true to get the configuration value
- * @param boolean $redirect whether to jump, if set to true to jump to the URL address
- * @param boolean $domain whether the domain name is displayed
- * @return String
- */
- U($url=',$vars=',$suffix=true,$redirect= false,$domain=false)
Copy Code
W function: Render output widget
- /**
- * Render Output Widget
- * @param string $name widget name
- * @param array $data parameters passed in
- * @param boolean $return whether to return content
- * @param string $path widget path
- * @return void
- */
- W($name, $data=array(), $return=false,$path=" )
thinkphp system built-in single letter function function