HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP Keywords : Create a constant and print its value
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.
Read more about constants in our PHP Constants Tutorial.
Create a constant and print its value:
<?php
class MyClass {
const MY_CONSTANT = 5;
}
echo
MyClass::MY_CONSTANT;
?>
❮ PHP Keywords