note 107683 added to function.settype

From: Date: Sun, 26 Feb 2012 00:00:44 +0000
Subject: note 107683 added to function.settype
Groups: php.notes 
Request: Send a blank email to php-notes+get-186366@lists.php.net to get a copy of this message
Note that you can't use this to convert a string 'true' or 'false' to a boolean variable true or false as a string 'false' is a boolean true. The empty string would be false instead... <?php $var = "true"; settype($var, 'bool'); var_dump($var); // true $var = "false"; settype($var, 'bool'); var_dump($var); // true as well! $var = ""; settype($var, 'bool'); var_dump($var); // false ?> ---- Server IP: 69.147.83.197 Probable Submitter: 62.212.72.166 ---- Manual Page -- http://www.php.net/manual/en/function.settype.php Edit -- https://master.php.net/note/edit/107683 Del: integrated -- https://master.php.net/note/delete/107683/integrated Del: useless -- https://master.php.net/note/delete/107683/useless Del: bad code -- https://master.php.net/note/delete/107683/bad+code Del: spam -- https://master.php.net/note/delete/107683/spam Del: non-english -- https://master.php.net/note/delete/107683/non-english Del: in docs -- https://master.php.net/note/delete/107683/in+docs Del: other reasons-- https://master.php.net/note/delete/107683 Reject -- https://master.php.net/note/reject/107683 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186366) next »