Home  >  Article  >  Backend Development  >  Usage examples of php boolean (Boolean) type

Usage examples of php boolean (Boolean) type

WBOY
WBOYOriginal
2016-07-25 08:57:431434browse
  1. /**
  2. * Detect boolean type in php
  3. * edit: bbs.it-home.org
  4. */
  5. var_dump((bool) ""); // bool(false)
  6. var_dump((bool) 1); // bool(true)
  7. var_dump((bool) -2); // bool(true)
  8. var_dump((bool) "foo"); // bool(true)
  9. var_dump((bool) 2.3e5); // bool(true)
  10. var_dump ((bool) array(12)); // bool(true)
  11. var_dump((bool) array()); // bool(false)
  12. var_dump((bool) "false"); // bool(true)
Copy code

Instructions: When converting Boolean to string, true=>1, false=>"";



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn