Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What are the rules for determine the "truth" of any value not already of the Boolean type?

user-image
Question ajoutée par Saadia Idris , Employee , Jazz Company
Date de publication: 2017/10/25
Ahmed Samir
par Ahmed Samir , Web Developer , Raqy Company for Electronic Trading

  1. If the value is a number, it is false if exactly equal to zero and true otherwise.
  2. If the value is a string, it is false if the string is empty (has zero characters) or is the string "0", and is true otherwise.
  3. Values of type NULL are always false.
  4. If the value is an array, it is false if it contains no other values, and it is true otherwise. For an object, containing a value means having a member variable that has been assigned a value.
  5. Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
  6. Don't use double as Booleans. 

More Questions Like This