PHP Cosntantas
PHP Cosntantas
A constant
value cannot change during the execution of the PHP script.
Here are some examples of valid and invalid constant names in PHP −
Explore our latest online courses and learn new skills at your own pace.
Enroll and become a certified expert to boost your career.
1.3.2 Example 1
The following example demonstrates how the define() function works −
Open Compiler
<?php
define("CONSTANT", "Hello world.");
echo CONSTANT;
// echo Constant;
?>
The first echo statement outputs the value of CONSTANT. You will get the
following output −
Hello world.