PHP 条件(值不同)


php condition (in different value)

php condition (在不同的值中)

如果$tt> 29 打印好,如果 $tt <55 打印非常好,但是当 $tt= 小于 0 时打印在 php 中非常糟糕

<?php
if( $tt > 29 ) {
 print "Good";
} else if( $tt > 29 &&  $tt < 55) {
 print "Very Good";
} else if( $tt < 0) {
 print "Very bad";
}
?>

你的问题也可能有漏洞,很少有数字与你的条件重叠,很少有没有条件的数字。

所以这是一个将打印的代码

  1. 对于小于或等于 0 的数字非常糟糕
  2. 对数字 1 到 29 不利
  3. 适合 30 至 55
  4. 非常适合55岁及以上

您可以根据需要进行编号

<?php
if( $tt <= 0 ) {
  echo "Very Bad";
} else if( $tt <= 29) {
  echo "Bad";
} else if( $tt <= 55) {
 echo "Good";
} else {
 echo "Very Good";
}
?>

你去吧

 <?php
 if( $tt > 29 ) {
  echo "Greater Than 29 ";
 } else if( $tt > 29 &&  $tt < 55) {
       echo "Greater Than 29 and less than 55 ";
 } else if( $tt < 0) {
  echo "less than zero ";
 }
 ?>