Hi Prabeen,
This is done using the isset keyword, which returns 1 if it is set or 0 if it is not.
It is important to note that if the variable is defined but set to 0 then it will still return 1.
<?php
function checksetting($var) {
if(isset($var)) { echo "Set"; } else { echo "Not set"; }
}
$a = 5; $b = 0;
checksetting($a); //set
checksetting($b); //set
?>
Mar 17, 2010