2

some time we use 0 value or 1 value for php, instead of 0 and 1 value, can we use True/False method in php.

3 Answers3

15

A boolean TRUE value is converted to the string "1". Boolean FALSE is converted to "" (the empty string). This allows conversion back and forth between boolean and string values.

http://us3.php.net/manual/en/language.types.string.php#language.types.string.casting

wind
  • 338
  • 2
  • 11
4

We converting the in boolean datatype in FALSE:

  • the boolean FALSE itself the integer 0 (zero)
  • the special type NULL (including unset variables)
  • an object with zero member variables (PHP 4 only) string "0"
  • SimpleXML objects created from empty tags
  • the empty string,and the
  • the float 0.0 (zero)
  • an array with zero elements

Every other value is considered TRUE.

-2

0 value is equal to false & value of 1 is equal to true

  • 6
    Please highlight and explain the addtional insight this answer provides in comparison to existing, older and upvoted answers. Answering without any original content might get you downvotes (though none of those existing now are by me). – Yunnosch Jan 18 '19 at 14:07
  • Consider taking the [tour], especially [answer]. – Yunnosch Jan 18 '19 at 14:08