Category Archives: Constants in php

Defining constants with example

Defn:

Constants are those whose value remains the same in executing environment.
How to define constants with example:

<?php
define("PI", 3.1415); //Defining a constant called PI
$r=5; //r for radius
$area = PI*$r*$r; //area calculation of circle
Echo "Areas of circle with radius $r is ".$area.".";
?>