MCQ practice | Free learning platform

Categories

Posted on 21 Sep, 2020 09:16 am, category: Science & Technology | Web Apps Development |

Check whether a variable is empty in PHP


$a = 0;


// true because variable a is empty.
if(empty($a)){
echo "Variable 'a' is empty";
}


// true because variable a is set.
if(empty($a)){
echo "Variable 'a' is set/declare ";
}
?>

The following values evaluate is empty:
0
0.0
""
NULL
False
array()

 


Copy Link to Share:
https://www.mcqpractice.com/auth/index.php?page=../proverbs/article-details.php&id=64&t=Check-whether-a-variable-is-empty-in-PHP

Posted on 21 Sep, 2020 09:16 am, Category:

Check whether a variable is empty in PHP


$a = 0;


// true because variable a is empty.
if(empty($a)){
echo "Variable 'a' is empty";
}


// true because variable a is set.
if(empty($a)){
echo "Variable 'a' is set/declare ";
}
?>

The following values evaluate is empty:
0
0.0
""
NULL
False
array()

 


More articles you may like







© 2018-2024 Privacy Policy  
        FAQ | Help | Contact