简体   繁体   中英

php condition (in different value)

php condition (IN DIFFERENT VALUE)

if $tt > 29 print Good , if $tt < 55 print Very good but when $tt= less than 0 print very bad in php

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

Your question has too may loopholes and few numbers are overlapping your conditions and few are comming in no condition.

So here is a code which will print

  1. very bad for number less than or equal to 0
  2. bad for number 1 to 29
  3. good for 30 to 55
  4. very good for 55 and above

You can chenge number based on your needs

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

Here you go

 <?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 ";
 }
 ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM