Php empty() method

PHP empty() method is used to check the variable has value or not. It gives output in a boolean value. if the variable empty then the output will be true or 1 and if the variable is not empty then the output will be false or 0.

Syntax:- to check the variable is empty


<?php
empty($variable_name)
?>

Example:- Suppose, You have employee_name variable which has empty value and now you want to check employee_name variable is empty or not.


<?php
$employee_name="";
if(empty($employee_name))
{
echo 'employee is empty';
}

?>
Output:- employee is empty

Try it Yourself