$sanitizer->bool() method

Convert the given value to a boolean

This differs from regular boolean type conversion in the following ways:

  • This method will recognize things like the strings "false" or "0" representing a boolean false.
  • If given an object, it will convert the object to a string before determining what boolean value it should represent.
  • If given an array, it returns false if the array contains zero items.


$bool = $sanitizer->bool($value);



Return value


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.214

Twitter updates

    Error retrieving Twitter status

Latest news

  • ProcessWire Weekly #473
    In the 473rd issue of ProcessWire Weekly we'll check out latest core updates, introduce new third party module called Template Fragment Controller, and more. Read on!
    Weekly.pw / 3 June 2023
  • A look at the new Page Edit Restore module
    The new Page Edit Restore module helps to prevent page edits in the admin from getting lost when the user’s session is lost. This post covers it in detail.
    Blog / 12 May 2023
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer