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 use the 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.

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

PHP define function syntax


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

The following is an example:

Here’s the output,

PHP constants define function

In the above example, 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
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading