当前位置:Gxlcms > PHP教程 > booleantrue/falseandthestrings"true"/"false&

booleantrue/falseandthestrings"true"/"false&

时间:2021-07-01 10:21:17 帮助过:9人阅读

Booleans are used to represent the concepts of true and false. They are most often used for testing if a statement is true or false and they'll play a bigger role when we discuss logical expressions.Note that there is a difference between boolean true/false and the strings "true"/"false".
  1. Booleans and NULL
  2. /* Booleans are used to represent the concepts of true and false.
  3. They are most often used for testing if a statement is true or false and
  4. they'll play a bigger role when we discuss logical expressions.
  5. Note that there is a difference between
  6. boolean true/false and the strings "true"/"false".
  7. */
  8. $bool1 = true;
  9. $bool2 = false;
  10. // When booleans are displayed, PHP will attempt to convert them into a string
  11. // You'll get either "1"/"0" or "1"/"" instead of true/false
  12. ?>
  13. $bool1:
  14. $bool2:

  15. /* NULL is used to represent the concept of nothing or the state of being empty
  16. In the below example three variable have been set,
  17. then boolean tests are performed and the results are output as a string
  18. */
  19. $var1 = 3;
  20. $var2 = "cat";
  21. $var4 = NULL;
  22. // isset tests whether a variable has been set
  23. // It returns true or false as a result of the test.
  24. ?>
  25. $var1 is set:
  26. $var2 is set:
  27. $var3 is set:
  28. $var1 is set:
  29. $var2 is set:
  30. $var3 is set:

  31. $var1 empty:
  32. $var4 empty:

人气教程排行