Learn PHP Constants 

PHP constants can be name, variable or identifier that can not be change on execution time . This can be define in two ways :

  • Using : define() Function
  • Using : Const

PHP constants can be useful while database connection , where you can define the values once that later can not be changed during execution. PHP constant follow the same PHP rules,variables can only start with  letters or underscores.

See This Example

<?php  
define(names, case-insensitive, values)  
?>  

Name: It define the name of constant 
Case-Insensitive : It define the  constant value
Value: It give option to change case sensitive , By default FASLE ( It means case sensitive)

See this example To know Better

<?php  
define("NAME","Akshay");  
echo NAME;  
?>  

Output:

Akshay


See Another Example  
<?php  
define("NAME","Hello I am akshay",true);//not case sensitive  
echo NAME.'<.br>';  
echo name;  
?>  

 Output:

Hello I am akshay
Hello I am akshay


WOW you are learning fast . May be you are genius :)


Last Updated: 2018-07-06 12:32:44 By akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :