The difference between PHP language structure (Language constructs) and functions

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 ($username [5])) {

The username is at least six characters long.

}

The reason is that isset is a language structure, and strlen is 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.

2. Why language structure is faster than function

The reason is that in PHP, the function must first be decomposed into the language structure of the PHP parser, so there is this visible, the function is more than the language structure of a layer of parser parsing. This can be better understood as

What language structure is faster than a function.

3. Differences in language structure and functions

L language structure is faster than corresponding function function

L language structure is relatively robust in error handling, because it is a language keyword, so there is no re-processing links

The L language structure cannot be disabled in configuration items (php.ini), and functions can.

L language structures cannot be used as callback functions

4. List of language structures

L Echo ()

L print (), yes, it's a language structure

L Die ()

L Isset ()

L unset ()

L include (), no include_once ()

L require (), no require_once ()

L Array ()

L list ()

L Empty ()

5. See what you have in your program?!

The difference between PHP language structure (Language constructs) and functions

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.