absint() in WordPress

Advertisement

It convert a value to non-negative integer.

Internally this function used abs( intval( $maybeint ) ).


You can try below examples yourself.

Examples Output var_dump
absint( 0 ) 0 int(0)
absint( '0' ) 0 int(0)
absint( 1 ) 1 int(1)
absint( '8' ) 8 int(8)
absint( -27 ) 27 int(27)
absint( '-8' ) 8 int(8)
absint( 'abc' ) 0 int(0)

[code language=”php”]
echo absint( 0 );
// Output: 0
// var_dump() int(0)

echo absint( ‘0’ );
// Output: 0
// var_dump() int(0)

echo absint( 1 );
// Output: 1
// var_dump() int(1)

echo absint( ‘8’ );
// Output: 8
// var_dump() int(8)

echo absint( -27 );
// Output: 27
// var_dump() int(27)

echo absint( ‘-8’ );
// Output: 8
// var_dump() int(8)

echo absint( ‘abc’ );
// Output: 0
// var_dump() int(0)

[/code]

Leave a Reply