PHP 5 Constant :-

Techno PHP

A constant is a unique value that can not be changed during the execution time .
Constant looks like a simple letter that is not written with $ sign .


Creation of constant :-

To create a constant we will use define() function .

Syntax

define(name, value, case-insensitive)

Details

Name- specified the name of constant


Value – Value of constant


Case-sensitive –define the constant should be case sensitive .


The example below creates a constant with a case-sensitive name:

Example


<?php
define("LEARN", "Learn on technosmarter.com!");
echo LEARN ;
?>
		
		
Run

Constants are gloabal variables that cross the entire script .
Let’s learn with an example .



Example


<?php
define("LEARN ", "Learn on technosmarter.com!");

function study() {
    echo LEARN;
}
 
study();
?
>
Run

Related