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 8537635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:56:52+00:00 2026-06-11T10:56:52+00:00

Reffer this link . I know operand with string type translate to number, and

  • 0

Reffer this link.

I know operand with string type translate to number, and then usual math

But see these sample codes:

echo intval(1e1);       // 10
var_dump("1e1" == 10);  // true, and it's ok

echo intval(0x1A);      // 26
var_dump("0x1A" == 26); // true, and it's ok

echo intval(042);       // 34
var_dump("042" == 34);  // fasle, Why ?!!!

Why last code return false.

  • 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-06-11T10:56:53+00:00Added an answer on June 11, 2026 at 10:56 am

    That’s because string-to-number conversion in PHP is based on some ancient C function – strtod. And its rules are as follows:

    The expected form of the (initial portion of the) string is optional
    leading white space as recognized by isspace(3), an optional plus
    (‘+’) or minus sign (‘-‘) and then either (i) a decimal number, or
    (ii) a hexadecimal number […]

    A decimal number consists of a nonempty sequence of decimal digits
    possibly containing a radix character (decimal point,
    locale-dependent, usually ‘.’), optionally followed by a decimal
    exponent. A decimal exponent consists of an ‘E’ or ‘e’, followed by
    an optional plus or minus sign, followed by a nonempty sequence of
    decimal digits, and indicates multiplication by a power of 10. [… ]

    A hexadecimal number consists of a “0x” or “0X” followed by a nonempty
    sequence of hexadecimal digits possibly containing a radix character,
    optionally followed by a binary exponent. […]

    As you see, ‘1e1’ string has non-empty sequence ‘1’ followed by a decimal exponent ‘e1’. So, it will be converted into a decimal number – and becomes 10.

    ‘0x1A’ string follows the rules for hexadecimal number, and will be converted into 26 accordingly. But as there’s no specific rule for octadecimal number, ‘042’ will be converted into a plain decimal – and becomes 42. Which is, of course, not equal to 34.

    This should not be confused with how number literals are parsed by PHP itself. A number literal that starts with 0 is considered representing an octadecimal. So, intval(042) is essentially the same as intval(34) – but not the same as intval("042").

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

Sidebar

Related Questions

I was trying to solve this issue recently, but i don't really know how.
Please refer to this background question. After constructing this COUNT, how would I then
I have this code I been working on but I'm having a hard time
I know something like this is possible, I'm pretty sure I'm just wording it
I know there are other naming convention discussions, but the ones I saw were
Refer to the figure below and this link . Regarding Figure 2.3, I understand
Refer to my previous question for context: Link Consider this situation: I upload the
basically I have a link like so: <a href=file.php?value=this&something=so&please=help>special link</a> And when I click
I want to know how this FFMPEG to integrate in php. I want to
In Erica Sadun's Download Helper, link here , I can put these methods into

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.