假设这个
function Args($a) {
if (/*HOW*/) {
echo "the argument is a pure number";
} else {
echo "the argument is a string";
}
}
Args(4); -> the argument is a pure number
Args("4"); -> the argument is a string
根据函数和示例,我如何才能获得差异,根据类型参数?
使用内置函数is_int($value)
或is_string($value)
is_int的手册在这里,此处的is_string手册
使用内置的gettype()
函数。
function Args($a) {
$type=gettype($a);
echo "the argument is a ".$type;
}