PHP Boolean

PHP Boolean Values

Boolean values are typically used in program control structures, such as if or If-Else. There are several conditions must be in use Boolean values, namely :

  • For integer and floating point, Boolean value is false if its value 0, otherwise is true
  • For strings, the Boolean value is false if empty string (""),otherwise is true.
  • For array data type, the value is false if the element is empty, otherwise is true.
  • For the data type object, false if no variable or function / method defined in it, otherwise is true.
  • For variables that can not be created or defined, its value is false.

In PHP, there are two keywords that is true and false. Where true represents an integer value and false represents an empty string. True and False keywords are not case sensitive.


Post a Comment