Differences between the PHP language structure and functions

Source: Internet
Author: User
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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.