PHP Constants
PHP Constants
A constant is case-sensitive by default.
By convention, constant identifiers are always uppercase.
Constants syntax
define(name, value, case-insensitive)
or
define(name, value)
Constants example
<html>
<body>
<?php
define("C1", "PHP beginner course<br />", true);
echo c1;
define("C2", "PHP advanced course<br />", false);
echo C2;
define("C3", "PHP online<br />");
echo C3;
define("C4", "Learn PHP Constants");
function functionTest() {
echo C4;
}
functionTest();
?>
</body>
</html>
Result
PHP beginner course
PHP advanced course
PHP online
Learn PHP Constants