I believe you often see comparisons in some PHP applications, saying that isset() is used to replace strlen(), and isset executes faster than strlen. F Example: (if (isset ($ user)) {
// do some things
}
The reason is that the isset is a language structure, and Strlen is a function. Also, echo is a language structure, not a function.
So what is language structure? Is it any different from a function?
1. What are language structures and functions
Language structure: It is the keyword of the PHP language and part of the language grammar; it cannot be defined by the user or added to language extensions or libraries; it may or may not exist Variables and return values.
Function: It is composed of code blocks and can be reused. From the perspective of source code, it is implemented based on the Zend engine. The functions in the ext extension library are implemented in this way.
2. The reason why language structures are faster than functions is that in PHP, functions are first decomposed into language structures by the PHP parser (Zend engine), so it can be seen that functions have one more layer of parsers than language structures. parse. In this way, you can better understand which language structures are faster than functions.
3. The difference between language structures and functions. Language structures are faster than corresponding functions. Language structures are more robust in error handling. Since they are language keywords, they do not have reprocessing links. Language structures cannot be used in configuration items ( php.ini), but the function can. Language structures cannot be used as callback functions
4. List of language structures
echo()
print()
die()
isset()
unset()
include(), note, include_once() is the function
require(). Note that require_once() is the function
array()
list()
empty()