


Summary of the use of ThinkPHP single letter functions (shortcut methods), thinkphp function_PHP tutorial
A summary of the use of ThinkPHP single-letter functions (shortcut methods), thinkphp functions
This article mainly introduces a summary of the use of ThinkPHP single-letter functions (shortcut methods), and focuses on ThinkPHP's shortcut methods. A summary of sex, friends who need it can refer to it There are many easy-to-use single-letter functions (i.e. shortcut methods) in ThinkPHP, which are easy for developers to call quickly, but alphabetical functions are not convenient to remember. This article summarizes all alphabetic functions to facilitate future search. .
1.U() URL assembly supports different URL patterns
?1 |
U( $url = '' , $vars = '' , $suffix =true, $domain =false)
|
@param string $url URL expression, format: '[module/controller/operation#anchor@domain name]?Parameter 1=value 1¶meter 2=value 2...'
@param string| array $vars Incoming parameters, supports arrays and strings
@param string $suffix Pseudo-static suffix, the default is true to obtain the configuration value
@param boolean $domain Whether to display the domain name
@return string
2.D() D function is used to instantiate model class format [resource://][module/]model
?1 |
D( $name = '' , $layer = '' )
|
@param string $name resource address
@param string $layer model layer name
@return Model
3.M() The M function is used to instantiate a Model without a model file
?1 |
M( $name = '' , $tablePrefix = '' , $connection = '' )
|
@param string $name Model name supports specifying basic models such as MongoModel:User
@param string $tablePrefix table prefix
@param mixed $connection database connection information
@return Model
4.I() gets input parameters and supports filtering and default values
?1 |
I( $name , $default = '' , $filter =null)
|
How to use:
?1 2 3 |
I( 'id' ,0); //获取id参数 自动判断get或者post
I( 'post.name' , '' , 'htmlspecialchars' ); //获取$_POST['name']
I( 'get.' ); //获取$_GET
|
5.B() perform a certain behavior
?1 |
B( $name , $tag = '' ,& $params =NULL)
|
@param string $name Behavior name
@param string $tag Tag name (behavior class does not need to be passed in)
@param Mixed $params Incoming parameters
@return void
6.C() Read and set configuration parameters
?1 |
C( $name =null, $value =null, $default =null)
|
@param string|array $name configuration variable
@param mixed $value configuration value
@param mixed $default default value
@return mixed
7.E() throws exception handling
?1 |
E( $msg , $code =0)
|
@param string $msg Exception message
@param integer $code Exception code Default is 0
@return void
8.G() records and counts time (microseconds) and memory usage
?1 |
G( $start , $end = '' , $dec =4)
|
How to use:
?1 2 3 4 5 |
G( 'begin' ); // 记录开始标记位
// ... 区间运行代码
G( 'end' ); // 记录结束标签位
echo G( 'begin' , 'end' ,6); //统计区间运行时间 精确到小数后6位
echo G( 'begin' , 'end' , 'm' ); // 统计区间内存使用情况
|
If the end mark bit is not defined, the current mark bit will be automatically used
The statistical memory usage requires MEMORY_LIMIT_ON constant to be true to be valid
@param string $start start tag
@param string $end End tag
@param integer|string $dec decimal place or m
@return mixed
9.L() gets and sets the language definition (case-insensitive)
?1 |
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 resource://module@theme/controller/operation
?1 |
T( $template = '' , $layer = '' )
|
@param string $name Template resource address
@param string $layer View layer (directory) name
@return string
11.N() Set and get statistics
?1 |
N( $key , $step =0, $save =false)
|
How to use:
?1 2 3 4 |
N( 'db' ,1); // 记录数据库操作次数
N( 'read' ,1); // 记录读取次数
echo N( 'db' ); // 获取当前页面数据库的所有操作次数
echo N( 'read' ); // 获取当前页面读取次数
|
@param string $key identification position
@param integer $step step value
@return mixed
12.A()A function is used to instantiate the controller
Format: [resource://][module/]controller
?1 |
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 controller operation method
URL parameter format [resource://][module/]controller/operation
?1 |
R( $url , $vars = array (), $layer = '' )
|
@param string $url calling address
@param string|array $vars calling parameters support strings and arrays
@param string $layer name of the control layer to be called
@return mixed
14.W() render output Widget
?1 |
W( $name , $data = array ())
|
@param string $name Widget name
@param array $data Incoming parameters
@return void
15.S() Cache Management
?1 |
S( $name , $value = '' , $options =null)
|
@param mixed $name cache name, if cache setting is for array representation
@param mixed $value cache value
@param mixed $options cache parameters
@return mixed
16.F() Fast file data reading and saving For simple type data strings, arrays
?1 |
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 of these shortcut methods, readers can refer to the relevant example tutorials on this site.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.