Difference between the Languageconstructs and functions

Source: Internet
Author: User
Source of the article: blog.sina.com.cnsblog_475429950100hk75.html I believe that we often see some PHP applications that use isset () to replace strlen (), and isset to execute faster than strlen. Example: if (isset ($ username [5]) {Theusernameisatleastsixcharacterslong .}

Article Source: http://blog.sina.com.cn/s/blog_475429950100hk75.html I believe that we often see a comparison of some PHP applications, said with isset () replace strlen (), isset faster than strlen execution. Example: if (isset ($ username [5]) {// The username is at least six characters long .}

Article Source: http://blog.sina.com.cn/s/blog_475429950100hk75.html

I believe we often see some PHP applications that use isset () to replace strlen (), and isset to execute faster than strlen.
Example:
If (isset ($ username [5]) {
// The username is at least six characters long.
}
The reason is that isset is a language structure, while strlen is 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.
2 ,? Why is the language structure faster than the function?
The reason is that in PHP, all functions are first decomposed into a language structure by the PHP parser. Therefore, we can see that the function has a layer of parser than the language structure. In this way, we can better understand why the language structure is faster than the function.
3 ,? Different language structures and functions
The language structure is faster than the corresponding function
The language structure is relatively robust in error handling. Because it is a language keyword, it does not have any further processing steps.
The language structure cannot be disabled in the configuration item (php. ini), and the function can.
The language structure cannot be used as a callback function.
4 ,? Language Structure list
Echo ()
Print (). That's right. This is a language structure.
Die ()
Isset ()
Unset ()
Include (), no include_once ()
Require (), no require_once ()
Array ()
List ()
Empty ()

Original article address: [convert] the difference between the PHP Language structure (Language constructs) and the function. Thank you for sharing it with the original author.

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.