#8. PHP Constant Variable

 

PHP Constant Variable Syntax

    define(name, value , case-insensitive)

define(num, 300, true)
define(_num, 300, true)
echo num;
echo NUM;    // this condition code will be execute

Can't use $ sign with the constant variable name

Constant Variables are Global Variables.

Run code:

<?php
define("test" , 40, true);
//define("test" , 20);     // Error 
//define("test" , 10, true);    // Error
//$sum = test+20;
//echo $sum;
//echo test;

?>

Comments

Popular posts from this blog

#30. PHP Recursive Function