Data

Constant

PHP

 

Defining Constant

PHP 5
define("PI", 3.14);

define("E", pow(
    pow(PI,4) + pow(PI,5), 1/6));

define declares a block-scoped Constant.

 

Getting Constant value

PHP 5
define("PI", 3.14);

$r = 2;
$area = $r * $r * PI;   // area -> 12.56

To get the value of a Constant, you can simply use it's name.

Remember that constants do not have $ before their name.