PHP language constructor introduction _ PHP Tutorial

Source: Internet
Author: User
Introduction to the PHP language constructor. 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. 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:

The code is as follows:


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.

The variable function you mentioned is variable function. translating it into a variable function is also a little distorted) the term is translated according to the meaning of the adjective (variable. The Variable function in PHP is a function with the same name and value as the Variable if a pair of parentheses is added to the Variable. if the Variable is found, the interpreter tries to execute it. For example, if there is a function foo (), you can use the following method to call this function:

The code is as follows:


// Initialize a string variable
$ Func = 'foo ';

// Find the function with the same name as this string and execute it
$ Func ();

Therefore, the meaning of the sentence you mentioned is that using a variable function to call a language is not allowed. for example:

The code is as follows:


$ Func = 'print ';

// This will cause an exception because print is not a function but a component of the language.
$ Func ('Hello World ');

When this code is executed, an exception occurs, and the print function is not defined.

....

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.