PHP Constant


Constants are variables that except once they are defined they cannot be undefined or changed.

A constant is an identifier or a name.
The value cannot be changed during the script.
A valid constant in PHP can be start with letter or underscore.
Create a PHP Constant ?
To create a constant in PHP, use the ‘define ()’ function ‘const’ keyword.
PHP constant using define ()-
Define (name, value)
name: Specifies the name of the constant.
value: Specifies the value of the constant.
Let's see the example to define PHP constant using define().

Output :

PHP constant using, const keyword-
(1) It is bit faster than define().
(2) It is always be case-sensitive.

Let's see the example to define PHP constant using const keyword.

Output :

Note :
Unlike variables, constants are automatically global across the entire script.
PHP echo Statements
echo used to print  output data to the screen.
The PHP echo Statement
The echo statement can be used with or without parentheses: echo or echo().

Output :

Content writer:
Er. Noman Rayeen
CSE 6th Sem

TSPC, Burhanpur

Related topics

Professor Jayesh video tutorial

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.