PHP: Constants

This entry is part 9 of 54 in the series PHP Tutorial

The syntax for defining constant is as below:

bool define ( string $name , mixed $value [, bool $case_insensitive = false ])


define("hello", "Hi There.");
echo hello; 
echo "<br>";
echo Hello; 
echo "<br>";

//To allow case insensitive, set the third parameter to be true.
define("greeting", "How are you?", true);
echo "<br>";
echo Greeting;

Try The Code

Note that there are 2 parts in the above code.  The top part is case sensitive and the second part is case insensitive.

You can try to run the code here.

Series Navigation<< PHP: Static variable
PHP: Variable with global keyword >>