PHP empty() Function

PHP floatval() Function
PHP doubleval() Function

In this article, you will learn how to check if a variable is empty or not in PHP. The empty() function in PHP checks whether a variable is empty or not. This function returns false if the variable exists and is not empty, otherwise it returns true.

what is the syntax of the EMPTY() function in php?

empty(variable);
ParameterDescription
variableRequired. Specifies the variable to check
PHP empty() method

examples of the EMPTY() function

Example 1. In this example, we check if a variable is empty. Also, check whether the variable is set/declared.

<?php
$a = 0;

// True because $a is empty
if (empty($a)) {
  echo "Variable 'a' is empty.<br>";
}

// True because $a is set
if (isset($a)) {
  echo "Variable 'a' is set";
}
?>
PHP floatval() Function
PHP doubleval() Function
en English
X
Scroll to Top