Example
Create a constant and print its value:
html
<?php
const MY_CONSTANT = 5;
echo MY_CONSTANT;
?>
Definition and Usage
The const keyword is used to create constants. Unlike with the define() function, constants created using the const keyword must be declared in the global scope.
Related Pages
More Examples
Example
Create a constant and print its value:
html
<?php
class MyClass {
const MY_CONSTANT = 5;
}
echo
MyClass::MY_CONSTANT;
?>