PHP Constants
PHP Constants
A valid constant name starts with a letter or underscore (no $ sign before the
constant name).
Note: Unlike variables, constants are automatically global across the entire
script.
Syntax
define(name, value, case-insensitive)
Parameters:
Example
<?php
define("GREETING", "Welcome to W3Schools.com!");
echo GREETING;
?>
Run example »
Run example »
Example
<?php
define("GREETING", "Welcome to W3Schools.com!");
function myTest() {
echo GREETING;
}
myTest();
?>