PHP - Operators & conditions

0 votes
313 views
added Nov 5, 2019 in PHP by LC Marshal Captain (25,790 points)
retagged Nov 5, 2019 by LC Marshal
<?php
// Condition for if $a greater than $b
if($a > $b){
  echo "Defender";
}

//Condition if $a not equal to $b
if($a != $b {
  echo "Defender";
}

//Condition if $a equal $b, otherwise echo "No"
$a = 'defender';
$b = 'discovery';
if($a == $b) {
  echo "Yes";
} 
else {
  echo "No";
}

//Condition for 3 situations with if, elseif, else
$a = 50;
$b = 10;
if($a == $b) {
  echo "1";
} 
elseif($a > $b) {
  echo "2";
} 
else {
  echo "3";
}
?>

 

1 Response

0 votes
responded Nov 5, 2019 by LC Marshal Captain (25,790 points)
<?php
// Condition Output $i so long $i lesser than 6

$i = 1; 

while ($i < 6) {
  echo $i;
  $i++;
}

?>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...