For a while i've been using: gettype();
to dynamically get the variable cast type, eg:
function Type ($Value = null){
return gettype($Value);
}
echo Type(array()); // Echo array
echo Type (1); // Echo integer
echo Type(1.2); // echo doubble
Whereas, i'm looking for a method to have a common and known integer representation which is I believe is easier to validate over traditional strings.
Does anyone have a possible solution for this?
I have something like this:
function Type ($Value = null){
$Type = gettype($Value);
if ($Type === "array"){
return 1;
}elseif ($Type === "integer"){
return 2;
}
// ...
}
This method gets the job done, but looks messy, and me being a kind of clean freak when it comes to my code... Is there something that looks more graceful?
How about this one: