Web Development & WordPress

isset(), empty() and is_numeric() in PHP

CODE:

<?php

$studentNum=0;
if(isset($studentNum)){
echo "value is set ";
}else{
    echo "value not set";
}
echo "<br>";
if(empty($studentNum)){
    echo "value is empty";
}else{
    echo "value not empty";
}
echo "<br>";
if(isset($studentNum) && (is_numeric($studentNum) || $studentNum !='')){
    echo "there is value and not empty";
}else{
    echo " not set or empty";
}
?>

OUTPUT:

value is set
value is empty
there is value and not empty

Leave a comment