Become Our Fan on Social Sites!

Facebook Twitter

Google+ RSS YouTube

Wednesday 18 December 2013

Use of define() function in PHP

Use of define() function is to set a constant. It has three parameters: first is name of the constant, second is value for the constant and third parameter for constant name should be case-insensitive.



1) Following example is case-sensitive constant name:

Output:
This is value of MYCONST

Source Code:

<?php
    define("MYCONST","This is value of MYCONST");
    echo MYCONST;
?>


2) Following example is case-insensitive constant name:

Output:
 This is value of MYCONST

Source Code:
<?php
    define("MYCONST","This is value of MYCONST",true);
    echo myconst;  
?> 

0 comments :

Post a Comment