Php constants and php constants _ PHP Tutorial

Source: Internet
Author: User
Php constants and php constants. Php constants. which define () functions of php constants are used to define constants. Once a constant is defined, it cannot be changed or undefined. Example of defining constants :? Phpdefine (CONSTA php constant, which php constants are there?

The define () function is used to define constants. Once a constant is defined, it cannot be changed or undefined.

Example of defining constants:

 

Run

Constant names and any other PHP labels follow the same naming rules. A valid constant name starts with a letter or underline followed by any letter, number, or underline.

Constants are case-sensitive by default, and constant identifiers are always capitalized. this value cannot be changed during script execution.

Differences between defining constants and variables:

  • No dollar sign before a constant ($)
  • Constants can only be defined using the define () function, but cannot be defined using the value assignment statement.
  • Constants can be defined and accessed anywhere, regardless of the variable range rules.
  • Once defined, a constant cannot be redefined or undefined.
  • The constant value can only be a scalar.

PHP has a large number of predefined constants. For more information, see The PHP Manual.

Address: http://www.manongjc.com/php/php_constant.html

Related reading:

Php str_pad () function to populate the string with the specified length

Analysis and explanation of php str_replace () string replacement function

The php str_ireplace () function replaces characters in strings with case-insensitive characters.

The php str_getcsv () function parses the CSV string into an array.

The includefine () function is used to define constants. Once a constant is defined, it cannot be changed or undefined. Example of defining constants :? Phpdefine ("CONSTA...

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.