Maison > développement back-end > tutoriel php > boolean true/false and the strings "true"/"false&

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

WBOY
Libérer: 2016-07-25 09:11:18
original
1605 Les gens l'ont consulté
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:
复制代码


source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal