PHP/String/is string
Implementing Custom Type Hinting
<source lang="html4strict">
<?php <?php function many_hints($int, $flt, $str) {
if (!(is_integer($int))) { trigger_error("$int is not of type integer", E_USER_ERROR); } if (!(is_float($flt))) { trigger_error("$flt is not of type float", E_USER_ERROR); } if (!(is_string($str))) { trigger_error("$str is not of type integer", E_USER_ERROR); } return ($int * $flt) . " " . $str;
}
echo "", many_hints(1992, .042, "dollars owed"), "
"; echo "", many_hints("bob", 3, true), "
";?>
</source>