Home > Article > Backend Development > PHP constants
Set PHP constants
To set constants, 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
The optional third This parameter specifies whether the constant name is case-sensitive. The default is false.
The following example creates a case-sensitive constant with the value "Welcome to W3School.com.cn!":
Instance
<?php define("GREETING", "Welcome to W3School.com.cn!"); echo GREETING; ?>
Running instance
The following example creates a case-insensitive constant, The value is "Welcome to W3School.com.cn!":
Instance
<?php define("GREETING", "Welcome to W3School.com.cn!", true); echo greeting; ?>