php define function usage: [define()] function defines a constant, the syntax is [define(name,value,case_insensitive)], defines a case-sensitive constant, the code is [define("GREETING ","Hello 】.
The operating environment of this tutorial: windows7 system, PHP5.6 version, DELL G3 computer. This method is suitable for all brands of computers.
Usage of php define function:
define()
The function defines a constant.
Constant is similar to a variable, except that:
After setting, the value of the constant cannot be changed
The constant name does not require a dollar sign ($) at the beginning
Scope does not affect access to constants
Constant values can only be strings or numbers
Syntax
define(name,value,case_insensitive)
Example 1
Define a case-insensitive constant:
<?php define("GREETING","Hello world!"); echo constant("GREETING"); ?>
Output:
Hello world!
Example 2
Define a case-insensitive constant :
<?php define("GREETING","Hello world!",TRUE); echo constant("greeting"); ?>
Output:
Hello world!
Related video recommendations: PHP programming from entry to proficiency
The above is the detailed content of What is the usage of php define function. For more information, please follow other related articles on the PHP Chinese website!