note 74664 added to ref.var

From: Date: Sun, 22 Apr 2007 23:16:13 +0000
Subject: note 74664 added to ref.var
Groups: php.notes 
Request: Send a blank email to php-notes+get-125772@lists.php.net to get a copy of this message
Here's a simple way of telling you what the variable is, like if it's string, integer, etc.: <?php if(!function_exists("gettype_array")) { function gettype_array($var) { $types = array("array","binary","bool","buffer", "callable","double","float","int", "integer","long","null","numeric", "object","real","resource","scalar", "string","unicode"); $i=0; $_call = ""; $return = array(); foreach($types as $type) { $_call = "is_".$type; if(@function_exists($_call)) { if($_call($var)) { $return[$i] = $type; $i += 1; } } $_call = ""; } return $return; } } ?> To demo: <?php $test = 1; $results = gettype_array($test); print_r($results); echo "\n\n"."Result #2 is a ".$results[2]."!"; ?> The results (depending on PHP version): Array ( [0] => int [1] => integer [2] => long [3] => numeric [4] => scalar ) Result #2 is a long! ---- Server IP: 69.39.81.135 Probable Submitter: 71.248.34.156 ---- Manual Page -- http://www.php.net/manual/en/ref.var.php Edit -- https://master.php.net/note/edit/74664 Del: integrated -- https://master.php.net/note/delete/74664/integrated Del: useless -- https://master.php.net/note/delete/74664/useless Del: bad code -- https://master.php.net/note/delete/74664/bad+code Del: spam -- https://master.php.net/note/delete/74664/spam Del: non-english -- https://master.php.net/note/delete/74664/non-english Del: in docs -- https://master.php.net/note/delete/74664/in+docs Del: other reasons-- https://master.php.net/note/delete/74664 Reject -- https://master.php.net/note/reject/74664 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125772) next »