Share EncyclopediaHome EncyclopediaCategories Switch Channel

Thinkphp single letter function (quick method)

2026-04-05 03:57850NameNetworking

This article focuses on a summary of the single letter function (quick method) used by thinkphp, and a targeted summary of the quickness method ofthinkphp is available to friends who need it. Down

Many of them use simple single-letter functions (i. E., shortcut methods), which can be easily called by developers quickly, but which cannot be remembered, and all of them are summarized here to facilitate subsequent 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@domainname

? Parameter 1 = value 1 = parameter 2 = value 2...'

@param string|array $vars input parameters, support arrays and strings

@param string $suffix pseudo-static suffix with the default to acquire configuration value

@param boolean $domain display domain names

@return string

2. D()d function for example-based model type format

Resources

Model

D

@param string $name resource address

@param string dollarlayer model name

@returnmodel

3. M()m function is used to exemplify a model without a model file

M ($name=', $tableprefix=', $co)♪ i'm not sure what you're talking about ♪

@paramstring $namemodel name supports specifying base model e. G. Mongomodel:user

@param string $tableprefix table prefix

@param mixed $coNneaction database connection information

@returnmodel

4. I() get input parameters to support filtering and default values

I ($name, $default=', $filter=null)

Methods of use:

I('id',0); ///get the id parameters automatically judge get or post i('post. Name','','HTMLspecialchars'); // get $ post i('get.'); / get $ get

5. B() performance of an act

B ($name, $tag=', $params=null)

@param string $name behavior name

@param string $tag tag name (behaviour class not required)

@param mised $params entered parameters

@returnvoid

6. C() read and set configuration parameters

C ($name=nul,$value=nul,$default=nul)

@param string|array $name configuration variable

@param mixed $value configuration value

@param mixed $default default

@return mixed

7. E() throwout abnormalities

E ($msg, $code=0)

@param string $msg abnormal message

@param integer $code anomaly default to 0

@returnvoid

8. G() record and measure time (microseconds) and memory usage

G ($start, $end=', $dec=4)

Methods of use:

G('begin'); / / record initial tag/ / ... Inter-area running code g('end'); / / record end-label echo g('begin','end', 6); / / statistical interval running time accurate to six decimal places echo g (`begin','end', 'm'); / statistical inter-area memory usage

If the end tag is not defined, the current tag is automatically used

Where statistical memory usage requires memory limit on constant to be valid

@param start $start

@param string fund end tab

@param integerworking $dec decimal or m

@return mixed

9. L()acquires and sets language definitions (without case-sensitive)

L ($name=null,$value=null)

@param string|array $name language variable

@param mixed $value language value or variable

@return mixed

10. T()acquire template files

Matt chat ai

Material science ai smart body platform, smart question and answer engine based on 280,000 + professional papers

Download

T ($temple=', $layer=')

@param string $name template resource address

@param string dollarlayer view layer (dirs) name

@return string

11. N() setting up and obtaining statistics

N ($key, $step=0, $save=false)

Methods of use:

N('db', 1); / / record the number of database operations n('read', 1); / / record the number of readouts echo n('db'); / / access all operations of the current page database echo n (`read'); / / access the number of readouts on the current page

@param string $key identification position

@param integer $step

@return mixed

12. A()a function is used for exemplifying controllers

Format:

Resources

Controller

A ($name, $layer=', $level=')

@param string $name resource address

@param string dollar player control name

@param integer $level controller level

@return coI'm sorry

13. R() remote call control operating method

Url parameter format

Resources

Controller/operation

R ($url, $vars=array(), $layer=')

@param string $url calling address

@param string|array $vars call parameters support string and number group

@param string $layer to call the control layer name

@return mixed

14. W() rendering outputwidget

W ($name, $data =array())

@param string $namewidget

@param array $data imported parameters

@returnvoid

15. S() cache management

S ($name, $value=', $options=null)

@param mixed $name cache name if grouping indicates cache settings

@param mixed $value cache value

@param mixed $options cache parameters

@return mixed

16. F() fast file data read and save for simple types of data string, array

F ($name, $value=', $path=data path)

@param string $name cache name

@param mixed $value cache value

@param string $path cache path

@return mixed

For the detailed operation of these shortcuts, the reader can refer to the relevant example curriculum on this site。

Php free learning video: immediately

On the front-end study tour, opening the way to mastery! From the front end to the project, step by step, step by step, to the top

Like 0
Report
Favorite 0
Tip 0
Comment 0
Share 4
MoreRelated Comments
No comments yet, be the first to comment