Code:
<?php
function functionAdd($n) {
$result = 0 ;
if(gettype($n)!='integer'){
echo "Invalid type";
}
for($i=1;$i<=$n;$i++){
$result+= $i;
}
echo $result.gettype($n);
}
functionAdd(5);
echo "<br>";
functionAdd("haha");
?>
Output:
15integer
Invalid type
