What are the rules for determine the "truth" of any value not already of the Boolean type?
Submitted by: AdministratorHere are the rules for determine the "truth" of any value not already of the Boolean type −
☛ If the value is a number, it is false if exactly equal to zero and true otherwise.
☛ 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.
☛ Values of type NULL are always false.
☛ 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.
☛ Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
☛ Don't use double as Booleans.
Submitted by:
☛ If the value is a number, it is false if exactly equal to zero and true otherwise.
☛ 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.
☛ Values of type NULL are always false.
☛ 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.
☛ Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
☛ Don't use double as Booleans.
Submitted by:
Read Online Sr. PHP Programmer Job Interview Questions And Answers
Top Sr. PHP Programmer Questions
☺ | What are the 3 scope levels available in PHP and how would you define them? |
☺ | What is the purpose of $_PHP_SELF variable in PHP? |
☺ | What is the purpse $_PHP_SELF variable? |
☺ | Can the value of a constant change during the script's execution? |
☺ | What is the purpose of _CLASS_ constant? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |