Home > Article > Backend Development > How to use define() function in php
How to use the define() function in php: The define() function is used to define a constant, syntax: [define(name,value,case_insensitive)]. For example: [define("GREETING","Hello world!")].
Function:
define() function is used to define a constant.
(Recommended tutorial: php video tutorial)
Grammar:
define(name,value,case_insensitive)
Parameter introduction:
name is required. Specifies the name of the constant.
value is required. Specifies the value of the constant.
case_insensitive Optional. Specifies whether constant names are case-sensitive. If set to true, it is not case sensitive. Default is false (case sensitive).
(Related recommendations: php training)
Example:
Define a case-sensitive constant:
<?php define("GREETING","Hello world!"); echo constant("GREETING"); ?>
Output:
Hello world!
Define a case-insensitive constant:
<?php define("GREETING","Hello world!",TRUE); echo constant("greeting"); ?>
Output:
Hello world!
The above is the detailed content of How to use define() function in php. For more information, please follow other related articles on the PHP Chinese website!