Guest User

Untitled

a guest
Jun 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. // Arbitrary default percentage and method.
  4. $default_percentage = 100;
  5.  
  6. // Get POST value.
  7. $percentage = $_POST['percentage'] ? $_POST['percentage'] : $default_percentage;
  8.  
  9. // Function to test percentage.
  10. function is_limited_percentage( $perc, $lower, $upper )
  11. {
  12. return $perc >= $lower && $perc <= $upper;
  13. }
  14.  
  15. if( is_limited_percentage( $percentage, 0, 100 ))
  16. {
  17. echo 'Percentage is between 0 and 100';
  18. } else
  19. {
  20. echo 'Percentage is invalid';
  21. }
  22.  
  23. /* End of script */
Add Comment
Please, Sign In to add comment