I have created a simple code to call the function in the else if condition but I want to know the better solution for this or How can we achieve this in a different manner if we have some data condition in any function which depends on the else if condition. Thanks
<?php
$a = 10;
$b = 20;
function getdata($a, $b)
{
if($a == $b)
{
return true;
}
else{
return false;
}
}
if ($a > $b) {
echo "if condition";
} elseif (getdata($a, $b)) {
echo "a is equal to b";
} else {
echo "a is smaller than b";
}
?>
Aucun commentaire:
Enregistrer un commentaire