How to Check If a Variable is Empty with the empty() Function in PHP

09/04/2021

Contents

In this article, you will learn how to check if a variable is empty with the empty() function in PHP.

PHP empty() Function

The empty() function checks if a variable is empty.

This function returns true if the value of the variable is empty, false otherwise.
Specifically, the following values ​​are considered empty:

  • 0
  • 0.0
  • “0”
  • “”
  • NULL
  • FALSE
  • array()

Syntax:

empty($variable);