PHP Constant

Last Updated: August 28, 2021

A constant is a variable except that once it is defined they cannot be changed or undefined.

Syntax

define(name, value, case-insensitive)

Parameters:

  • name: You can specify the name of the constant
  • value: You can specify the value of the constant
  • case-insensitive: You can specify whether the constant name should be case-insensitive. Default is false (case sensitive)

Define value of Pi  ( π ) in math :

<?php
define("PI", "3.14");
echo PI;
?>