|
| HOW TO USE THE empty() FUNCTION IN PHP
The empty() function is used to check whether a defined variable has a value which is an empty string, empty array, zero or NULL. Returns true if it is and false if it is not empty or undefined. Please note the the empty() function only works on variables and it's use on anything else will produce errors.
Example Usage:
<?
$username='';
if(empty($username))
{
echo "This variable is empty";
}
else
{
echo "This variable is not empty";
}
?>
In the above example, the output will be: This variable is empty. This is because $username has an empty string '' as value.
|
|