note 98261 added to function.gettype

From: Date: Fri, 04 Jun 2010 17:20:44 +0000
Subject: note 98261 added to function.gettype
Groups: php.notes 
Request: Send a blank email to php-notes+get-169893@lists.php.net to get a copy of this message
This is my work around for the gettype warning. Hope some find it useful. <?php /** * Returns the type of the passed var * - PHP warns against using gettype(), this is my workaround * * @param mixed $var * @return string */ public function fetchType($var) { switch ($var) { case is_null($var): $type='NULL'; break; case is_bool($var): $type='boolean'; break; case is_float($var): $type='double'; // $type='float'; break; case is_int($var): $type='integer'; break; case is_string($var): $type='string'; break; case is_array($var): $type='array'; break; case is_object($var): $type='object'; break; case is_resource($var): $type='resource'; break; default: $type='unknown type'; break; } return $type; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 63.103.168.2 ---- Manual Page -- http://www.php.net/manual/en/function.gettype.php Edit -- https://master.php.net/note/edit/98261 Del: integrated -- https://master.php.net/note/delete/98261/integrated Del: useless -- https://master.php.net/note/delete/98261/useless Del: bad code -- https://master.php.net/note/delete/98261/bad+code Del: spam -- https://master.php.net/note/delete/98261/spam Del: non-english -- https://master.php.net/note/delete/98261/non-english Del: in docs -- https://master.php.net/note/delete/98261/in+docs Del: other reasons-- https://master.php.net/note/delete/98261 Reject -- https://master.php.net/note/reject/98261 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169893) next »