PHP Constant

Solve your problems or get new ideas with basic brainstorming

马上开始. 它是免费的哦
注册 使用您的电邮地址
PHP Constant 作者: Mind Map: PHP Constant

1. Set a PHP Constant

1.1. To set a constant, use the define() function - it takes three parameters: The first parameter defines the name of the constant, the second parameter defines the value of the constant, and the optional third parameter specifies whether the constant name should be case-insensitive. Default is false.

1.2. The example below creates a case-sensitive constant, with the value of "Welcome to W3Schools.com!": <?php define("GREETING", "Welcome to W3Schools.com!"); echo GREETING; ?> Will result : "Welcome to W3Schools.com!"

2. What is that?

2.1. A constant is an identifier (name) for a simple value. The value cannot be changed during the script.

2.2. A valid constant name starts with a letter or underscore (no $ sign before the constant name).

2.3. Note: Unlike variables, constants are automatically global across the entire script.