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

Usage examples of php boolean (Boolean) type

WBOY
Release: 2016-07-25 08:57:43
Original
1513 people have browsed it
  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=>"";



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template