mercredi 17 juillet 2019

is it possible to calculate in the if-statement? [duplicate]

This question already has an answer here:

I'm trying to "calculate" a prime number with an if statement and I want to define the calculation in the if statement

<?php
function prime($pNumber){
if (($pNumber%1=$pNumber) && ($pNumber%$pNumber=0)) {
echo $pNumber ." is a prime number.";
}else {
echo $pNumber . "is not a prime number";
}



}

I was expecting that if i call the function with say 6 it would go through the if statement 6%6=0 6%1=0 and yes I know I cant calculate a prime that way. I'm just wondering if I can use an if statement in that way.

Aucun commentaire:

Enregistrer un commentaire