Rumah  >  Artikel  >  pembangunan bahagian belakang  >  boolean true/false and the strings "true"/"false&

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

WBOY
WBOYasal
2016-07-25 09:11:181579semak imbas
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:
复制代码


Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:再次分享一个中文验证码 Artikel seterusnya:验证码文件类