"PHP Learning" PHP Constants

Source: Internet
Author: User

constants are similar to variables, but constants cannot be changed or revoked once defined. PHP Constants

A constant is an identifier (name) for a single value. The value cannot be changed in the script.

Valid constant names begin with a character or underscore (there is no $ symbol in front of the constant name).

Note: Unlike variables, constants are automatically global throughout the script. Set PHP Constants

To set a constant, use the Define () function-it uses three parameters:

    1. The first parameter defines the name of the constant
    2. The second parameter defines the value of a constant
    3. The optional third parameter specifies whether the constant name is case-sensitive. The default is False.

The following example creates a case -sensitive constant with a value of "Welcome to w3school.com.cn!" : Instance

<? PHP Define ("Greeting", "Welcome to w3school.com.cn!" ); Echo greeting;? >

Running an instance

The following example creates a case -insensitive constant with a value of "Welcome to w3school.com.cn!" : Instance

<? PHP Define true ); Echo greeting;? >
Running an instance

"PHP Learning" PHP Constants

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.