I\'m running a PHP script and continue to receive errors like:
Notice: Undefined variable: my_variable_name in C:\\wamp\\www\\mypath\\index.php on line 10
In PHP you need fist to define the variable after that you can use it.
We can check variable is defined or not in very efficient way!.
//If you only want to check variable has value and value has true and false value.
//But variable must be defined first.
if($my_variable_name){
}
//If you want to check variable is define or undefine
//Isset() does not check that variable has true or false value
//But it check null value of variable
if(isset($my_variable_name)){
}
Simple Explanation
//It will work with :- true,false,NULL
$defineVarialbe = false;
if($defineVarialbe){
echo "true";
}else{
echo "false";
}
//It will check variable is define or not and variable has null value.
if(isset($unDefineVarialbe)){
echo "true";
}else{
echo "false";
}