absint() WP 2.5.0
Convert a value to non-negative integer. Analog of abs( intval( $foo ) )
.
No Hooks.
Return
Int. A non-negative integer.
Usage
absint( $maybeint );
- $maybeint(mixed) (required)
- Data you wish to have converted to a non-negative integer.
Examples
#1 Examples of how the function processes the transmitted data:
echo absint( 'number' ); // 0 echo absint( 0 ); // 0 echo absint( 10 ); // 10 echo absint( -10 ); // 10 echo absint( '-10' ); // 10 echo absint( 10.5 ); // 10 echo absint( '10.5' ); // 10 echo absint( 'str' ); // 0 echo absint( 'str-10' ); // 0 echo absint( '-10str' ); // 10 echo absint( '10str' ); // 10 echo absint( true ); // 1 echo absint( false ); // 0 echo absint( array('12') ); // 1 echo absint( array() ); // 0
Changelog
Since 2.5.0 | Introduced. |
Code of absint() absint WP 5.6
function absint( $maybeint ) {
return abs( (int) $maybeint );
}Related Functions
From category: Formatting
- add_magic_quotes()
- antispambot()
- backslashit()
- balanceTags()
- capital_P_dangit()
- convert_smilies()
- ent2ncr()
- force_balance_tags()
- links_add_target()