<?php
function foo($v) {
if (!is_numeric($v)) {
invalidArgument(__FUNCTION__, 'numeric', 1, gettype($v));
}
echo $v;
}
function invalidArgument($func, $type, $argN, $argT)
{
$db = debug_backtrace();
user_error(
sprintf(
"Argument %d passed to %s() must be a valid %s, %s given in %s on line %d",
$argN,
$func,
$type,
$argT,
$db[1]['file'],
$db[1]['line']
),
E_USER_ERROR
);
}
foo("9999999999999999999999999999999");
foo("abc");