Introduction to PHP constants and system constants _php Tutorial

Source: Internet
Author: User
PHP Changshime is considered case-sensitive. Traditionally, constant identifiers are always capitalized.

The PHP constant name and any other PHP tags follow the same naming conventions. A valid constant name begins with a letter or underscore followed by any letter, number, or underscore. This is expressed in regular expressions: [a-za-z_\x7f-\xff][a-za-z0-9_\x7f-\xff]*.

Copy the Code code as follows:

A valid constant name
Define ("FOO", "something");
Define ("FOO2", "something Else");
Define ("Foo_bar", "something More");

Illegal constant name
Define ("2FOO", "something");

The following definitions are legal, but should be avoided: (Custom constants do not start with __)
Maybe someday php will define a __foo__ magic constant.
This will conflict with your code.
Define ("__foo__", "something");

?>

Summarize:
1. Custom Constants
* Must be defined with function define ()
* The value cannot be changed after the definition is complete
* Use the constant name directly, not the same as the variable in the front plus $s

2 System constants:
File:P hp program filename
Line:P HP program file lines
Php_version: The version number of the current parser
Php_os: Executes the current PHP version of the operating system name
__file__ the file name of the script that is currently being processed.
__LINE__ the current number of rows in the script file currently being processed, as in the previous.

True indicates truth (true).
False indicates a pseudo-value (false).

E_error This constant refers to the most recent error.
E_warning This volume refers to the nearest warning point.
E_parse This constant is a potential problem in parsing syntax.

http://www.bkjia.com/PHPjc/769239.html www.bkjia.com true http://www.bkjia.com/PHPjc/769239.html techarticle PHP Changshime is considered case-sensitive. Traditionally, constant identifiers are always capitalized. The PHP constant name and any other PHP tags follow the same naming conventions. A valid constant name is a letter or a stroke ...

  • Related Article

    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.