PHP Constants

PHP Constants

A constant once defined, cannot be undefined. A valid constant name starts with a letter or underscore (no $ sign before the constant name). PHP constants uses define() function for creating a constant.

Constant name starts with a letter or underscore, but they can’t be considered as a variable, since constant name once defined can’t be changed.

define() function is used for creating a constant. Here’s the syntax:

PHP define function syntax

Here,

name is the constant name
val is the value of the constant
case-insensitive is for constant name insensitive.

Here’s the output,

PHP constants define function

Above, you can see we haven’t mentioned the case section, since the default is false. If you want a case-insensitive name, use true i.e

We used the define() function, since it is used for creating a constant.

PHP Data types
PHP Operators
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create free tutorials for all.

No Comments

Post A Comment