Which Values Are Considered Falsy in PHP?

List of all falsy values in PHP

In PHP, the following values are considered falsy:

  • Boolean false;
  • Integer 0;
  • Float 0.0 and -0.0;
  • Empty String;
  • String "0";
  • Array with no elements, [];
  • NULL type;
  • SimpleXML objects that are created from empty elements (i.e. elements that have no children and attributes).

These values evaluate to a boolean false when:

  1. They're explicitly converted to a boolean (for example by casting);
  2. An operator, function or control structure requires a boolean argument (in which case the value is converted to a boolean implicitly/automatically).

Hope you found this post useful. It was published . Please show your love and support by sharing this post.