Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:10:07+00:00 2026-05-24T19:10:07+00:00

Does php’s is_int function return false for negative numbers because integers in php are

  • 0

Does php’s is_int function return false for negative numbers because integers in php are unsigned, or is there other behaviour that I’m missing? I’m trying to check if something is a whole number, and I don’t want to rely on that behaviour of is_int (for the first part of the test) if it’s doing something different.

Clarification: I know that is_int returns false for negative numbers, but I’m asking why because of this behaviour: var_dump(intval("-10")) prints int(-10), and var_dump(intval("10")) prints int(1), so both negative and positive values are considered integers, yet is_int("-10") returns false.

EDIT: Ok, sorry everyone, I got quite a bit confused about the behaviour of is_int and integers in general. I was thinking of it acting on a string with contents like “-10” when what I need is is_numeric on a string, or is_int on an integer itself. Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:10:08+00:00Added an answer on May 24, 2026 at 7:10 pm

    It doesn’t:

    var_dump( is_int(-10) ); // bool(true)
    

    Probably, it isn’t a number to begin with:

    var_dump( is_int('-10') ); // bool(false)
    

    If so, try out is_numeric(), which is designed for strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain what the following PHP Code does function query($query_string) { if ($query_string
How does PHP's function xmlrpc_encode_request() work? Does it need the value of allow_url_fopen set
really quick question does php 5 still support include_once because I am getting some
I wrote this function to get a subset of an array. Does php have
Does php support friend function like as c++ supports?
Does PHP have any standard function(s) to convert Unicode strings to plain, good old-fashioned
Does php have a function to automatically convert dates to their day value, where
Does anyone know how PHP maps session IDs to $_SESSION arrays? In other words,
Does PHP include any function like toupper and tolower ? I want a tolower
Does PHP's hash function supported WHIRLPOOL by default? I believe it does but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.