PHP what is a language constructor and variable functions-PHP source code

Source: Internet
Author: User
It was found that the isset function of PHP in the boiled fish was more efficient than that of array_key_exists by mistake. The isset function of PHP in the boiled fish was more efficient than array_key_exists by mistake:

Script ec (2); script

Because isset belongs to the language structure in php, and array_key_exists is a function, isset is faster. In addition, isset also exists in other languages and is more readable.

I am confused. What is isset actually not a function? As for the processing efficiency, isset is faster, which is less important (at least I have been using isset and have hardly followed array_key_exists. For details, see the article)

In PHP.net, it is also divided into Variable handling functions, but in fact there is such a paragraph in the middle:

Note: A language constructor rather than a function cannot be called by a variable function.

PHP contains several special keywords, such as echo, print, die, and require. Although they are used as functions, they are actually similar to control statements like if and while, rather than a function. That is, when the interpreter encounters:

Print 'Hello world ';
In such an expression, it is not converted into a function call, but directly mapped to a series of pre-defined operations. When using a language, you can add parentheses or do not add parentheses, but you must add parentheses when using a function.

Variable Function visibility: http://www.php.net/manual/zh/functions.variable-functions.php

$ Func = 'foo ';
$ Func (); // This callfoo ()
$ Func = 'bar ';
$ Func ('test'); // This callbar ()
$ Func = 'echoit ';
$ Func ('test'); // This callechoit ()
If

$ Func = 'print ';
// This will cause an exception because print is not a function but a component of the language.
$ Func ('Hello World ');
If you write this statement, an error is reported.

In the PHP source code, isset is written as follows:


Obviously, it is not a function writing method.
I have a long experience.

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.