WordPress at a glance

absint() WP 2.5.0

Convert a value to non-negative integer. Analog of abs( intval( $foo ) ).

Возвращает

Int. A non-negative integer.

No Hooks.

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

Список изменений

С версии 2.5.0 Введена.

Code of absint() WP 5.5.1

wp-includes/functions.php
<?php
function absint( $maybeint ) {
	return abs( intval( $maybeint ) );
}

Related Functions

From category: Formatting

vladlu 100vlad.lu
Editors: kama 100
No comments
    Log In . Register