absint( mixed $maybeint ): int
Converts a value to non-negative integer.
Parameters
-
$maybeint
mixed Required -
Data you wish to have converted to a non-negative integer.
Return
int A non-negative integer.
Source
File: wp-includes/functions.php
.
View all references
function absint( $maybeint ) {
return abs( (int) $maybeint );
}
Related
Used By
Used By | Description |
---|---|
WP_REST_Menu_Items_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Prepares a single post output for response. |
WP_REST_Menu_Items_Controller::prepare_item_for_database() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Prepares a single post for create or update. |
WP_REST_Pattern_Directory_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php |
Prepare a raw block pattern before it gets output in a REST API response. |
build_query_vars_from_query_block() wp-includes/blocks.php |
Helper function that constructs a WP_Query args array from a |
get_sitemap_url() wp-includes/sitemaps.php |
Retrieves the full URL for a sitemap. |
get_metadata_raw() wp-includes/meta.php |
Retrieves raw metadata value for the specified object. |
wp_filter_content_tags() wp-includes/media.php |
Filters specific tags in post content and modifies their markup. |
WP_Sitemaps::render_sitemaps() wp-includes/sitemaps/class-wp-sitemaps.php |
Renders sitemap templates based on rewrite rules. |
wp_get_user_request() wp-includes/user.php |
Returns the user request object for the specified request ID. |
wp_validate_user_request_key() wp-includes/user.php |
Validates a user request by comparing the key with the request’s key. |
wp_send_user_request() wp-includes/user.php |
Send a confirmation request email to confirm an action. |
WP_Privacy_Requests_Table::get_views() wp-admin/includes/class-wp-privacy-requests-table.php |
Get an associative array ( id => link ) with the list of views available on this table. |
WP_Privacy_Requests_Table::prepare_items() wp-admin/includes/class-wp-privacy-requests-table.php |
Prepare items to output. |
_wp_privacy_resend_request() wp-admin/includes/privacy-tools.php |
Resend an existing request and return the result. |
_wp_privacy_completed_request() wp-admin/includes/privacy-tools.php |
Marks a request as completed by the admin and logs the current timestamp. |
_wp_personal_data_handle_actions() wp-admin/includes/privacy-tools.php |
Handle list table actions. |
WP_User::for_site() wp-includes/class-wp-user.php |
Sets the site to operate on. Defaults to the current site. |
WP_Customize_Manager::handle_load_themes_request() wp-includes/class-wp-customize-manager.php |
Loads themes into the theme browsing/installation UI. |
WP_Roles::for_site() wp-includes/class-wp-roles.php |
Sets the site to operate on. Defaults to the current site. |
wpdb::parse_db_host() wp-includes/class-wpdb.php |
Parses the DB_HOST setting to interpret it for mysqli_real_connect(). |
WP_Community_Events::__construct() wp-admin/includes/class-wp-community-events.php |
Constructor for WP_Community_Events. |
WP_Community_Events::cache_events() wp-admin/includes/class-wp-community-events.php |
Caches an array of events data from the Events API. |
WP_Customize_Manager::_validate_header_video() wp-includes/class-wp-customize-manager.php |
Callback for validating the header_video value. |
get_header_video_url() wp-includes/theme.php |
Retrieves header video URL for custom header. |
get_header_video_settings() wp-includes/theme.php |
Retrieves header video settings. |
WP_REST_Users_Controller::prepare_item_for_database() wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php |
Prepares a single user for creation or update. |
WP_REST_Users_Controller::delete_item() wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php |
Deletes a single user. |
WP_REST_Comments_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Retrieves a list of comment items. |
WP_Term_Query::parse_query() wp-includes/class-wp-term-query.php |
Parse arguments passed to the term query with default query parameters. |
get_current_network_id() wp-includes/load.php |
Retrieves the current network ID. |
WP_Network_Query::get_network_ids() wp-includes/class-wp-network-query.php |
Used internally to get a list of network IDs matching the query vars. |
wp_localize_jquery_ui_datepicker() wp-includes/script-loader.php |
Localizes the jQuery UI datepicker. |
WP_HTTP_Requests_Response::set_status() wp-includes/class-wp-http-requests-response.php |
Sets the 3-digit HTTP status code. |
WP_Site_Query::get_site_ids() wp-includes/class-wp-site-query.php |
Used internally to get a list of site IDs matching the query vars. |
get_oembed_response_data_rich() wp-includes/embed.php |
Filters the oEmbed response data to return an iframe embed code. |
get_post_embed_html() wp-includes/embed.php |
Retrieves the embed code for a specific post. |
get_oembed_response_data() wp-includes/embed.php |
Retrieves the oEmbed response data for a given post. |
get_header_image_tag() wp-includes/theme.php |
Creates image tag markup for a custom header image. |
wp_get_attachment_image_srcset() wp-includes/media.php |
Retrieves the value for an image attachment’s ‘srcset’ attribute. |
wp_get_attachment_image_sizes() wp-includes/media.php |
Retrieves the value for an image attachment’s ‘sizes’ attribute. |
wp_calculate_image_sizes() wp-includes/media.php |
Creates a ‘sizes’ attribute value for an image. |
_wp_get_image_size_from_meta() wp-includes/media.php |
Gets the image size as array from its meta data. |
WP_HTTP_Response::set_status() wp-includes/class-wp-http-response.php |
Sets the 3-digit HTTP status code. |
WP_Comment_Query::get_comment_ids() wp-includes/class-wp-comment-query.php |
Used internally to get a list of comment IDs matching the query vars. |
wp_handle_comment_submission() wp-includes/comment.php |
Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. |
WP_Customize_Cropped_Image_Control::to_json() wp-includes/customize/class-wp-customize-cropped-image-control.php |
Refresh the parameters passed to the JavaScript via JSON. |
WP_Customize_Nav_Menus::search_available_items_query() wp-includes/class-wp-customize-nav-menus.php |
Performs post queries for available-item searching. |
WP_Customize_Nav_Menus::ajax_load_available_items() wp-includes/class-wp-customize-nav-menus.php |
Ajax handler for loading available menu items. |
WP_Customize_Nav_Menus::ajax_search_available_items() wp-includes/class-wp-customize-nav-menus.php |
Ajax handler for searching available menu items. |
wp_ajax_crop_image() wp-admin/includes/ajax-actions.php |
Ajax handler for cropping an image. |
get_avatar_data() wp-includes/link-template.php |
Retrieves default data about the avatar. |
Custom_Background::ajax_background_add() wp-admin/includes/class-custom-background.php |
Handles Ajax request for adding custom background context to an attachment. |
WP_List_Table::get_pagenum() wp-admin/includes/class-wp-list-table.php |
Gets the current page number. |
wp_check_locked_posts() wp-admin/includes/misc.php |
Checks lock status for posts displayed on the Posts screen. |
wp_refresh_post_lock() wp-admin/includes/misc.php |
Checks lock status on the New/Edit Post screen and refresh the lock. |
wp_refresh_post_nonces() wp-admin/includes/misc.php |
Checks nonce expiration on the New/Edit Post screen and refresh if needed. |
wp_dashboard() wp-admin/includes/dashboard.php |
Displays the dashboard. |
add_submenu_page() wp-admin/includes/plugin.php |
Adds a submenu page. |
get_media_item() wp-admin/includes/media.php |
Retrieves HTML form for modifying the image attachment. |
media_upload_form() wp-admin/includes/media.php |
Outputs the legacy media upload form. |
wp_ajax_save_attachment_order() wp-admin/includes/ajax-actions.php |
Ajax handler for saving the attachment order. |
wp_ajax_get_attachment() wp-admin/includes/ajax-actions.php |
Ajax handler for getting an attachment. |
wp_ajax_save_attachment() wp-admin/includes/ajax-actions.php |
Ajax handler for updating attachment attributes. |
wp_ajax_save_attachment_compat() wp-admin/includes/ajax-actions.php |
Ajax handler for saving backward compatible attachment attributes. |
wp_ajax_wp_link_ajax() wp-admin/includes/ajax-actions.php |
Ajax handler for internal linking. |
wp_ajax_get_comments() wp-admin/includes/ajax-actions.php |
Ajax handler for getting comments. |
wp_ajax_replyto_comment() wp-admin/includes/ajax-actions.php |
Ajax handler for replying to a comment. |
wp_ajax_autocomplete_user() wp-admin/includes/ajax-actions.php |
Ajax handler for user autocomplete. |
wp_prepare_revisions_for_js() wp-admin/includes/revision.php |
Prepare revisions for JavaScript. |
WP_Comments_List_Table::get_views() wp-admin/includes/class-wp-comments-list-table.php | |
WP_Comments_List_Table::__construct() wp-admin/includes/class-wp-comments-list-table.php |
Constructor. |
wp_nav_menu_item_post_type_meta_box() wp-admin/includes/nav-menu.php |
Displays a meta box for a post type menu item. |
wp_nav_menu_item_taxonomy_meta_box() wp-admin/includes/nav-menu.php |
Displays a meta box for a taxonomy menu item. |
get_pending_comments_num() wp-admin/includes/comment.php |
Gets the number of pending comments on a post or posts. |
Custom_Image_Header::get_header_dimensions() wp-admin/includes/class-custom-image-header.php |
Calculate width and height based on what the currently selected theme supports. |
Custom_Image_Header::ajax_header_crop() wp-admin/includes/class-custom-image-header.php |
Gets attachment uploaded by Media Manager, crops it, then saves it as a new object. Returns JSON-encoded object details. |
Custom_Image_Header::ajax_header_add() wp-admin/includes/class-custom-image-header.php |
Given an attachment ID for a header image, updates its “last used” timestamp to now. |
Custom_Image_Header::ajax_header_remove() wp-admin/includes/class-custom-image-header.php |
Given an attachment ID for a header image, unsets it as a user-uploaded header image for the active theme. |
Custom_Image_Header::step_2() wp-admin/includes/class-custom-image-header.php |
Display second step of custom header image page. |
Custom_Image_Header::step_3() wp-admin/includes/class-custom-image-header.php |
Display third step of custom header image page. |
Custom_Image_Header::js_2() wp-admin/includes/class-custom-image-header.php |
Display JavaScript based on Step 2. |
Custom_Background::wp_set_background_image() wp-admin/includes/class-custom-background.php | |
WP_Customize_Manager::register_controls() wp-includes/class-wp-customize-manager.php |
Registers some default controls. |
sanitize_option() wp-includes/formatting.php |
Sanitizes various option values based on the nature of the option. |
wp_rand() wp-includes/pluggable.php |
Generates a random non-negative number. |
wp_get_archives() wp-includes/general-template.php |
Displays archive links based on type and format. |
WP_Query::get_posts() wp-includes/class-wp-query.php |
Retrieves an array of posts based on query variables. |
WP_Query::parse_query() wp-includes/class-wp-query.php |
Parse a query string and set query type booleans. |
WP_Query::parse_tax_query() wp-includes/class-wp-query.php |
Parses various taxonomy related query vars. |
get_current_blog_id() wp-includes/load.php |
Retrieve the current site ID. |
get_status_header_desc() wp-includes/functions.php |
Retrieves the description for the HTTP status. |
number_format_i18n() wp-includes/functions.php |
Converts float number to format based on the locale. |
WP_Widget_Recent_Comments::update() wp-includes/widgets/class-wp-widget-recent-comments.php |
Handles updating settings for the current Recent Comments widget instance. |
WP_Widget_Recent_Comments::form() wp-includes/widgets/class-wp-widget-recent-comments.php |
Outputs the settings form for the Recent Comments widget. |
WP_Widget_Recent_Comments::widget() wp-includes/widgets/class-wp-widget-recent-comments.php |
Outputs the content for the current Recent Comments widget instance. |
WP_Widget_Recent_Posts::widget() wp-includes/widgets/class-wp-widget-recent-posts.php |
Outputs the content for the current Recent Posts widget instance. |
WP_Widget_Recent_Posts::form() wp-includes/widgets/class-wp-widget-recent-posts.php |
Outputs the settings form for the Recent Posts widget. |
get_post_comments_feed_link() wp-includes/link-template.php |
Retrieves the permalink for the post comments feed. |
rss_enclosure() wp-includes/feed.php |
Displays the rss enclosure for the current post. |
WP_User_Query::prepare_query() wp-includes/class-wp-user-query.php |
Prepares the query variables. |
wp_video_shortcode() wp-includes/media.php |
Builds the Video shortcode output. |
wp_get_attachment_image() wp-includes/media.php |
Gets an HTML img element representing an image attachment. |
add_image_size() wp-includes/media.php |
Registers a new image size. |
set_post_thumbnail() wp-includes/post.php |
Sets the post thumbnail (featured image) for the given post. |
wp_get_recent_posts() wp-includes/post.php |
Retrieves a number of recent posts. |
is_sticky() wp-includes/post.php |
Determines whether a post is sticky. |
get_post_custom() wp-includes/post.php |
Retrieves post meta fields, based on post ID. |
url_to_postid() wp-includes/rewrite.php |
Examines a URL and try to determine the post ID it represents. |
get_bookmarks() wp-includes/bookmark.php |
Retrieves the list of bookmarks. |
wp_xmlrpc_server::mw_getRecentPosts() wp-includes/class-wp-xmlrpc-server.php |
Retrieves list of recent posts. |
wp_xmlrpc_server::mt_getRecentPostTitles() wp-includes/class-wp-xmlrpc-server.php |
Retrieves the post titles of recent posts. |
wp_xmlrpc_server::blogger_getRecentPosts() wp-includes/class-wp-xmlrpc-server.php |
Retrieves the list of recent posts. |
wp_xmlrpc_server::wp_getMediaLibrary() wp-includes/class-wp-xmlrpc-server.php |
Retrieves a collection of media library items (or attachments). |
wp_xmlrpc_server::wp_getComments() wp-includes/class-wp-xmlrpc-server.php |
Retrieves comments. |
wp_xmlrpc_server::wp_newComment() wp-includes/class-wp-xmlrpc-server.php |
Creates a new comment. |
wp_xmlrpc_server::wp_getPosts() wp-includes/class-wp-xmlrpc-server.php |
Retrieves posts. |
wp_xmlrpc_server::wp_getTerms() wp-includes/class-wp-xmlrpc-server.php |
Retrieves all terms for a taxonomy. |
wp_xmlrpc_server::wp_getUsers() wp-includes/class-wp-xmlrpc-server.php |
Retrieves users. |
wp_xmlrpc_server::_insert_post() wp-includes/class-wp-xmlrpc-server.php |
Helper method for wp_newPost() and wp_editPost(), containing shared logic. |
WP_Customize_Header_Image_Control::enqueue() wp-includes/customize/class-wp-customize-header-image-control.php | |
WP_Customize_Header_Image_Control::render_content() wp-includes/customize/class-wp-customize-header-image-control.php | |
wp_new_comment() wp-includes/comment.php |
Adds a new comment to the database. |
delete_metadata() wp-includes/meta.php |
Deletes metadata for the specified object. |
metadata_exists() wp-includes/meta.php |
Determines if a meta field with the given key exists for the given object ID. |
_WP_Editors::wp_link_query() wp-includes/class-wp-editor.php |
Performs post queries for internal linking. |
add_metadata() wp-includes/meta.php |
Adds metadata for the specified object. |
update_metadata() wp-includes/meta.php |
Updates metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added. |
Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
When passing a negative integer, you’ll get the non-negative, absolute value. Passing a non-int string returns 0, but passing -10, returns 10:
When passing float, it will return integer value
Please note, due to a rounding error (https://bugs.php.net/bug.php?id=33731) you may sometimes get unexpected results for calculations like this:
As to math and floating numbers there are results to consider when using
absint()
. Here are some tests.Prints:
0 returns 0
1 returns 1
-1 returns 1
-1 + 1 returns 0
1 * -1 returns 1
1 / -1 returns 1
1 - 1 returns 0
0 * -1 returns 0
0 / 1 returns 0
0 - 1 returns 1
0.99 * 1 returns 0
1.99 * 1 returns 1
0.99 / 1 returns 0
1.99 / 1 returns 1