PHP Tutorial

A web server programming language.

PHP Constants

PHP Constants

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

Create a PHP Constant

To create a constant, use the define() function.

Syntax: define(name, value, case-insensitive)

  • name: Specifies the name of the constant
  • value: Specifies the value of the constant

Constants are global and can be used across the entire script.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics