note 112575 added to function.boolval
| From: | luigi_cangiano at hotmail dot it | Date: | Mon, 01 Jul 2013 08:28:30 +0000 |
| Subject: | note 112575 added to function.boolval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195416@lists.php.net to get a copy of this message | ||
// Hack for old php versions to use boolval()
if(!function_exists('boolval')) {
function boolval($var = null) {
$back = false;
switch(gettype($var)) {
case 'boolean':
$back = $var;
break;
case 'float':
case 'double':
$var = intval($var);
case 'integer':
$back = $var !== 0;
break;
case 'string':
switch(strtolower($var)) {
case 'y':
case 's':
case 'true':
case 'vero':
case '1':
$back = true;
break;
case 'n':
case 'false':
case 'falso':
case '0':
$back = false;
break;
default:
$back = (bool)$var;
}
break;
default:
$back = (bool)$var;
break;
}
return $back;
}
}
----
Server IP: 69.147.83.199
Probable Submitter: 85.33.184.204
----
Manual Page -- http://php.net/manual/en/function.boolval.php
Edit -- https://master.php.net/note/edit/112575
Del: integrated -- https://master.php.net/note/delete/112575/integrated
Del: useless -- https://master.php.net/note/delete/112575/useless
Del: bad code -- https://master.php.net/note/delete/112575/bad+code
Del: spam -- https://master.php.net/note/delete/112575/spam
Del: non-english -- https://master.php.net/note/delete/112575/non-english
Del: in docs -- https://master.php.net/note/delete/112575/in+docs
Del: other reasons-- https://master.php.net/note/delete/112575
Reject -- https://master.php.net/note/reject/112575
Search -- https://master.php.net/manage/user-notes.php