empty()
functionYou can use the PHP empty()
function to find out whether a variable is empty or not. A variable is considered empty if it does not exist or if its value equals FALSE
.
Let's try out the following example to understand how this function basically works:
<?php
$var1 = '';
$var2 = 0;
$var3 = NULL;
$var4 = FALSE;
$var5 = array();
// Testing the variables
if(empty($var1)){
echo 'This line is printed, because the $var1 is empty.';
}
echo "<br>";
if(empty($var2)){
echo 'This line is printed, because the $var2 is empty.';
}
echo "<br>";
if(empty($var3)){
echo 'This line is printed, because the $var3 is empty.';
}
echo "<br>";
if(empty($var4)){
echo 'This line is printed, because the $var4 is empty.';
}
echo "<br>";
if(empty($var5)){
echo 'This line is printed, because the $var5 is empty.';
}
?>
i hope you like this small article.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to create jQuery slide up and down toggle effect
Use the jQuery slideUp() and&n...Bootstrap Typehead Demo with PHP and MySql
In this post, i am going to show you how...Javascript selector
With Javascript, you can change HTML ele...How to Install MongoDB on Ubuntu 16.04
Today, Laravelcode share with you how to...How to Execute Raw Queries in Laravel 8
Hello guys, Sometimes you have raw SQ...