0
PHP Function
In the school my challenge was to write a function in PHP to check if a number is odd, is true unless its false. <?PHP function numberodd($number) if($numer / 2){ echo:"The numer" $numer "is divisible"; } else{echo:"The numer" $numer "ist not divisible";} ?> numberodd(7); Is that correct?
2 odpowiedzi
+ 2
1. put "{" and "}" when declaring the function
2. delete ":" after "echo"
3. instead of "/" use "%"
<?PHP
function numberodd($number){
if($number%2){
echo "The numer ".$number." is not divisible <br />";
}
else{
echo "The numer ".$number." is divisible <br />";
}
}
numberodd(7);
numberodd(6);
?>
0
WoW thank you so much!