The difference between the language structure and the function of PHP

Source: Internet
Author: User
Tags php language
I believe you often see a comparison of some PHP applications, said to replace strlen () with Isset (), isset than strlen execution speed and so on.

Example:

if (Isset ($user)) {

Do some thing

}

The reason is that isset is a language structure, and strlen is a function. And Echo is a language structure, not a function.

What is the language structure? Is it different from the function?

1. What are language structures and functions

Language structure: is the PHP language keywords, language grammar part; it can not be defined by the user or added to the language extension or library; it can have or can have no variables and return values.

Function: consists of blocks of code that can be reused. From the source point of view, that is, based on the Zend engine base to achieve, Ext expansion library functions are implemented.

2, why the language structure is faster than the function of the reason is in PHP, the function must first be the PHP parser (Zend Engine) decomposition into a language structure, so there is this visible, function than the language structure more than a layer of parser parsing. This can be better understood, what language structure is faster than the function.

3, the language structure and function of the different language structure than the corresponding function of the function of the fast language structure is relatively robust in error handling, because it is a language keyword, so there is no re-processing link language structure can not be disabled in the configuration item (php.ini), function. The language structure cannot be used as a callback function

4. List of language structures

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.