Source of the article: blog.sina.com.cnsblog_475429950100hk75.html I believe that we often see some PHP applications that use isset () to replace strlen (), and isset to execute faster than strlen. Example: if (isset ($ username [5]) {Theusernameisatleastsixcharacterslong .}
Article Source: http://blog.sina.com.cn/s/blog_475429950100hk75.html I believe that we often see a comparison of some PHP applications, said with isset () replace strlen (), isset faster than strlen execution. Example: if (isset ($ username [5]) {// The username is at least six characters long .}
Article Source: http://blog.sina.com.cn/s/blog_475429950100hk75.html
I believe we often see some PHP applications that use isset () to replace strlen (), and isset to execute faster than strlen.
Example:
If (isset ($ username [5]) {
// The username is at least six characters long.
}
The reason is that isset is a language structure, while strlen is a function. What is the language structure? Is it different from a function?
1 ,? What are language structures and functions?
Language Structure: a keyword of the PHP language, part of the language syntax. It cannot be defined or added to language extensions or libraries. It can have or have no variables or return values.
Function :??? It consists of code blocks and can be reused.
2 ,? Why is the language structure faster than the function?
The reason is that in PHP, all functions are first decomposed into a language structure by the PHP parser. Therefore, we can see that the function has a layer of parser than the language structure. In this way, we can better understand why the language structure is faster than the function.
3 ,? Different language structures and functions
The language structure is faster than the corresponding function
The language structure is relatively robust in error handling. Because it is a language keyword, it does not have any further processing steps.
The language structure cannot be disabled in the configuration item (php. ini), and the function can.
The language structure cannot be used as a callback function.
4 ,? Language Structure list
Echo ()
Print (). That's right. This is a language structure.
Die ()
Isset ()
Unset ()
Include (), no include_once ()
Require (), no require_once ()
Array ()
List ()
Empty ()
Original article address: [convert] the difference between the PHP Language structure (Language constructs) and the function. Thank you for sharing it with the original author.