note 93051 added to function.is-bool

From: Date: Thu, 20 Aug 2009 21:18:18 +0000
Subject: note 93051 added to function.is-bool
Groups: php.notes 
Request: Send a blank email to php-notes+get-159718@lists.php.net to get a copy of this message
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 ---- Server IP: 80.241.173.5 Probable Submitter: 62.196.28.249 ---- Manual Page -- http://www.php.net/manual/en/function.is-bool.php Edit -- https://master.php.net/note/edit/93051 Del: integrated -- https://master.php.net/note/delete/93051/integrated Del: useless -- https://master.php.net/note/delete/93051/useless Del: bad code -- https://master.php.net/note/delete/93051/bad+code Del: spam -- https://master.php.net/note/delete/93051/spam Del: non-english -- https://master.php.net/note/delete/93051/non-english Del: in docs -- https://master.php.net/note/delete/93051/in+docs Del: other reasons-- https://master.php.net/note/delete/93051 Reject -- https://master.php.net/note/reject/93051 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159718) next »