Sunday, 27 July 2014

Filled Under:

constant in php

Constant in php

                                        The constant in php is simple value whose value does not change in whole script of php. We use define() function in php for initialize the value of constant. We do not use $ before constant  like php variable. The constant name is start with letter or underscore. Its name with be global in whole php program. For if we making a website then server name and username and password will not be change in whole website then we declare it as constant there are many more example this is more common example.

Syntax:

             Define(constant name, value, true/false);
By default its value will be false it its value will be false then it mean it is case-sensitive if its value will be true then it is case-insensitive.

Example:

<?php
define(“LOVE”, ”programming is my love”);
echo LOVE;
echo “”<br/>
define(“LOVE”, ”programming is my love”,true);
echo love;
?>

Output:

           Programming is my love 
           Programming is my love
           


                                




0 comments:

Post a Comment