Home > Article > Backend Development > How to use define modification function in php?
Usage of define modification function in php: 1. After setting, the value of the constant cannot be changed; 2. The constant name does not need the dollar sign [$] at the beginning; 3. The scope does not affect the use of the constant Access; 4. Constant values can only be strings or numbers.
definemodify the use of function in php:
Definition and usage
#define()
The function defines a constant.
Constants are similar to variables, the difference is:
After setting, the value of the constant cannot be changed
Constant The name does not need to start with a dollar sign ($)
The scope does not affect access to constants
The constant value can only be a string or Number
Syntax
define(name,value,case_insensitive)##Example 1Define a case-sensitive Constant:
<?php define("GREETING","Hello world!"); echo constant("GREETING"); ?>Output:
Hello world!Example 2Define a case-insensitive constant:
<?php define("GREETING","Hello world!",TRUE); echo constant("greeting"); ?>Output:
Hello world!
Related learning recommendations:
The above is the detailed content of How to use define modification function in php?. For more information, please follow other related articles on the PHP Chinese website!