I don't know where I am going wrong with my code and I am asking for some guidance as I am new to PHP.
I am trying to do an If else statement that will display if the random integer is odd or even. When I run the code it keeps on showing 'Number is odd' or nothing and I am not sure why. Any guidance will be much appreciated.
$RandomValue = rand(0, 10);
$OddValues = (1 || 3 || 5 || 7 || 9);
$EvenValues = (0 || 2 || 4 || 6 || 8 || 10);
if($RandomValue == $OddValues) {
echo $RandomValue, ' Number is odd';
} else {
if($RandomValue == $EvenValues)
echo $RandomValue, ' Number is even';
}
Aucun commentaire:
Enregistrer un commentaire