Posted: Wed Jul 26, 2006 5:00 pm
i suck lolol oh well
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
onion2k wrote:If, like me, you're forced to maintain PHP4 code, you can sort of do the same with..
Quite handy for library classes.Code: Select all
<?php function php4TypeHinting($var) { $type = gettype($var); if ($type=="resource") { $type = get_resource_type($var); } if ($type=="object") { $type = get_class($var); } return $type; } ?>
Code: Select all
<?php
function php4TypeHinting($var) {
$type = gettype($var);
if ($type=="resource") { $type = get_resource_type($var); ***return $type;}
if ($type=="object") { $type = get_class($var); }
return $type;
}
?>the best of the reasons indeedDaedalus- wrote:because that way he only writes it once rather than twice?
Yes:feyd wrote:The only primitive that has typehinting support beyond objects is array, and that was added in 5.1, if memory serves.
Errare humanum estDaedalus- wrote:My mistake
Better yet..julian_lp wrote:kool, but I wonder why you didnt write the return after the first if...
Code: Select all
<?php function php4TypeHinting($var) { $type = gettype($var); if ($type=="resource") { $type = get_resource_type($var); ***return $type;} if ($type=="object") { $type = get_class($var); } return $type; } ?>
Code: Select all
<?php
function php4TypeHinting($var) {
switch ($type = gettype($var)) {
case "resource": return get_resource_type($var); break;
case "object": return get_class($var); break;
default: return $type; break;
}
}
?>