note 93051 deleted from function.is-bool by cmb
| From: | cmb@php.net | Date: | Fri, 01 Feb 2019 14:40:50 +0000 |
| Subject: | note 93051 deleted from function.is-bool by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210174@lists.php.net to get a copy of this message | ||
Note Submitter: moty66 at gmail dot com
----
Here is the function which I use when pasring boolean variables from config files
<?php
function boolVal($var) {
switch ($var) {
case $var == true:
case $var == 1:
// case $var == '1': // no need for this, because we used
// $val == 1 not $var === 1
case strtolower($var) == 'true':
case strtolower($var) == 'on':
case strtolower($var) == 'yes':
case strtolower($var) == 'y':
$out = 1;
break;
default: $out = 0;
}
return $out;
}
?>
I am woundering why php does not have a function to do this
Motaz Abuthiab