Last active
March 1, 2016 20:48
-
-
Save lenivene/cee26986776de570a5f8 to your computer and use it in GitHub Desktop.
Check if number is positive | negative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Check number is positive | |
* PHP Version required >= 4.0 | |
*/ | |
function is_num_negative( $num ){ | |
if( empty( trim( $num ) ) || ! is_numeric( $num ) ){ | |
return; | |
} | |
/* | |
* Zero is number neutral | |
* Example: If on a seesaw two people stay in middle, What happens? Do you understand? | |
*/ | |
if( $num <= -1 ){ | |
return true; | |
}else{ | |
return; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Check number is positive | |
* PHP Version required >= 4.0 | |
*/ | |
function is_num_positive( $num ){ | |
if( empty( trim( $num ) ) || ! is_numeric( $num ) ){ | |
return; | |
} | |
/* | |
* Zero is number neutral | |
* Example: If on a seesaw two people stay in middle, What happens? Do you understand? | |
*/ | |
if( $num >= 1 ){ | |
return true; | |
}else{ | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment