Common predefined constants and instances in PHP

Source: Internet
Author: User
In PHP, you can use predefined constants to obtain information in PHP. Common predefined constants are as follows: In PHP, you can use predefined constants to obtain information in PHP.

Common predefined constants in PHP are as follows:

Constant name Description
_ FILE __ The default constant is the PHP program file name.
_ LINE __ Default constant, which is the number of PHP programs
PHP_ OS A built-in constant is the name of the operating system that executes the PHP parser.
PHP_VERSION The built-in constant is the PHP program version.
TRUE This constant is a true value.
FALSE This constant is a dummy value.
NULL A null value
E_ERROR Error, resulting in termination of php script
E_WARNING Warning, does not cause the php script to stop running
E_PARSE Parsing error reported by the program parser
E_NOTICE Non-critical errors, such as variable not initialized

Note: "" in FILE and LINE is two underscores rather than one "_".

Note: predefined constants starting with E _ are part of PHP error debugging.


PHP pre-defined constant instance:

The usage of predefined constants is no different from that of custom constants. The following uses a predefined constant to output information in PHP.

 Current number of PHP programs: ". LINE; echo"
Current PHP program version: ". PHP_VERSION; echo"
Current operating system: ". PHP_ OS;?>

The output result is similar to the following:

PHP program current file path: D: \ phpStudy \ www \ index. phpPHP program current number of lines: 3 current PHP program version: 5.6.27 current operating system: WINNT

Note: The results may vary depending on the operating system and software version used by each user.

The above are common predefined constants and instance details in PHP. For more information, see other related articles in the first PHP community!

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.