Home Tutorial Php PHP Variables Case Sensitive

 
 

Share on Google+Share on Google+
PHP Variables Case Sensitive
Posted on: January 11, 2010 at 12:00 AM
Advertisement
A variable is the location where we stores the value or information according to the which data types it belongs to. While declaring the variable in PHP, we always keep in mind that PHP is case sensitive.

PHP Variables Case Sensitive

A variable is the location where we stores the value or information according to the which data types it belongs to. While declaring the variable in PHP, we always keep in mind that PHP is case sensitive. You should always remember that in which case you define the variable at the time of declaring . For example :

<?php

$var_Cold = "December and January is the coldest month!";

$VAR_cold = "December is the coldest month of the year!";

echo $var_Cold."<br/>";

echo $VAR_cold;

?>

The output is : December and January is the coldest month!
                           December is the coldest month of the year!

In this example, we used two different variables $var_Cold and $VAR_cold both are different in their cases but the variable are same. Also, you can see the output is also different. Let see another example and you will understand in a better way:

<?php

$num = 15;

$NUM = 20;

$sum = $num + $NUM;

echo "num + NUM = ".$sum;

?>

The output is : num + NUM = 35.

In the above example we used three variable of same data type. The first two variables are same but different in their cases and also assign with distinct values. The third variable $sum which is used to add the values of first two variables.

Let see one more example where we used two variables of same cases and the output will be the interesting one :

<?php

$num = 15;

$num = 20;

$sum = $num + $num;

 

echo "num + num = ".$sum;

?>

The output is : num + num = 40.

Advertisement

Related Tags for PHP Variables Case Sensitive :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 11, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com