Using absint() in WordPress

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)
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)

Advertisements

Author: Mahesh Waghmare

I'm a professional WordPress theme/plugin developer since 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.