dokan_validate_boolean( mixed $var )

Description #

This function check if the passed arguments is a boolean and return true if it is a boolean, false otherwise.

Important Note #

This function uses FILTER_VALIDATE_BOOLEAN constant in PHP filter_var function. FILTER_VALIDATE_BOOLEAN tries to be smart, recognizing words like Yes, No, Off, On, both string and native types of true and false, and is not casesensitive when validating strings. So passing ‘Yes’, ‘off’, ‘on’ as dokan_validate_boolean function argument will be treated as true/false. Please see usage for some examples.

Return #

(bool)

Params #

None

Usage #

dokan_validate_boolean( 'Yes' )     // returns true
dokan_validate_boolean( 'on' )      // returns true
dokan_validate_boolean( 'true' )    // returns true
dokan_validate_boolean( 'no' )      // returns false
dokan_validate_boolean( 'off' )     // returns false
dokan_validate_boolean( 'false' )   // returns false
dokan_validate_boolean( 1 )         // returns true
dokan_validate_boolean( 0 )         // returns false

Leave a Reply

Your email address will not be published. Required fields are marked *