I believe we often see some PHP applications that use isset () to replace strlen (), and isset to execute faster than strlen. Example: if (isset ($ user) {dosomething} is because isset is a language structure, and strlen is a function. Echo is also a language structure, not a function. What is the language structure? It is in comparison with the function... we believe that in some PHP applications, we often see that isset () is used to replace strlen (), and isset is faster than strlen.
Example:
If (isset ($ user )){
// Do some thing
}
The reason is that isset is a language structure, while strlen is a function. Echo is also a language structure, not 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. From the source code perspective, it is implemented based on the Zend Engine. functions in the ext Extension Library are implemented in this way.
2. Why is the language structure faster than functions? in PHP, functions are first decomposed into language structures by the PHP parser (Zend Engine, functions have a higher parser than the language structure. In this way, we can better understand what language structure is faster than the function.
3. different language structures of language structures and functions are faster than those of corresponding functions. the language structure is relatively robust in error handling, because it is a language keyword, therefore, the language structure that does not have the re-processing link cannot be used in the configuration item (php. ini), function. The language structure cannot be used as a callback function.
4. Language Structure List
Echo ()
Print ()
Die ()
Isset ()
Unset ()
Include (). Note that include_once () is a function.
Require (). Note that require_once () is a function.
Array ()
List ()
Empty ()