Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Arbitrary default percentage and method.
- $default_percentage = 100;
- // Get POST value.
- $percentage = $_POST['percentage'] ? $_POST['percentage'] : $default_percentage;
- // Function to test percentage.
- function is_limited_percentage( $perc, $lower, $upper )
- {
- return $perc >= $lower && $perc <= $upper;
- }
- if( is_limited_percentage( $percentage, 0, 100 ))
- {
- echo 'Percentage is between 0 and 100';
- } else
- {
- echo 'Percentage is invalid';
- }
- /* End of script */
Add Comment
Please, Sign In to add comment