Created
October 9, 2010 20:02
-
-
Save jamsesso/618552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ! | |
* PHP typeof() function - Similar to the JavaScript method. | |
* Usage: if(typeof($phpQuery) == "undefined") require_once "phpQuery.php"; | |
* if(typeof($_GET) == "array") echo "There are \$_GET arguments present."; | |
* etc... | |
* Author: Sam Jesso | |
* URI: http://sammm.net/ | |
* Date: Sun, 9 Oct, 2010 | |
* */ | |
function typeof($argument) | |
{ | |
$return = array("string", "integer", "float", "boolean", "null", "array", "object", "undefined"); | |
if(is_string($argument)) | |
return $return[0]; | |
elseif(is_int($argument)) | |
return $return[1]; | |
elseif(is_float($argument)) | |
return $return[2]; | |
elseif(is_bool($argument)) | |
return $return[3]; | |
elseif(is_null($argument)) | |
return $return[4]; | |
elseif(is_array($argument)) | |
return $return[5]; | |
elseif(is_object($argument)) | |
return $return[6]; | |
endif; | |
return $return[7]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment