boolean true/false and the strings "true"/"false&

WBOY
发布: 2016-07-25 09:11:18
原创
1600 人浏览过
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:
复制代码


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板