absint()
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. |
absint() absint code WP 6.7.2
function absint( $maybeint ) { return abs( (int) $maybeint ); }