PHP

Constants in PHP


Define() function, define constants in PHP

Examples of constants definition in PHP

Defining constants in PHP. The following code shows a warning and error when defining constants that are case insensitive.

<?php 

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);

define("CONST_VARIABLE", "Constant value");

echo "Case sensitive constant: ". CONST_VARIABLE. "<br/>";

// This will let call the constant without case sensitive option

// Gives a warning since case insensitive is not supported anymore
define("CONST_VARIABLE_CS", "Constant value No Case Sensitive", true);

echo "Non case sensitive constant: ".CONST_VARIABLE_cs. "<br/>";