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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:43:50+00:00 2026-06-16T00:43:50+00:00

I have the typical problem with big int decoded with json_decode and try using

  • 0

I have the typical problem with big int decoded with json_decode and try using the JSON_BIGINT_AS_STRING option, but it seems that php ignores the parameter.

I tried the php.net example code:

$json = '12345678901234567890';

var_dump(json_decode($json));
var_dump(json_decode($json, false, 512, JSON_BIGINT_AS_STRING));

The output should be:

float(1.2345678901235E+19)
string(20) "12345678901234567890"

But in my server (xampp php 5.4.7) I have:

float(1.2345678901235E+19)
float(1.2345678901235E+19)

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-06-16T00:43:51+00:00Added an answer on June 16, 2026 at 12:43 am

    EDIT:

    I had to confirm this, but this behavior has been classified as a bug in PHP. Please see the bug report for more details.

    The existing behavior causes your string to be cast as int/float (number type) internally by PHP. If you provide a JSON encoded object, array, or string the function does what it describes, but for now this reflects the buggy behavior.

    $json = '12345678901234567890';
    
    var_dump(json_decode($json));           /* float(1.2345678901235E+19) */
    var_dump(json_decode($json, false, 512, 
             JSON_BIGINT_AS_STRING));       /* float(1.2345678901235E+19) */
    

    As you can see both give us a float, but when we use a valid JSON object, array, or valid JSON as a string we get the expected result.

    $jsonStr = '"12345678901234567890"';        // as a string
    $jsonArr = '[12345678901234567890]';        // as an array
    $jsonObj = '{"num":12345678901234567890}';  // as an object
    
    var_dump(
             json_decode($jsonStr), /* It's JSON_BIGINT_AS_STRING by default in 5.4 */
             json_decode($jsonArr),
             json_decode($jsonArr, false, 512, JSON_BIGINT_AS_STRING),
             json_decode($jsonObj),
             json_decode($jsonObj, false, 512, JSON_BIGINT_AS_STRING)
    );
    

    The output looks like the following…

    string(20) "12345678901234567890"
    array(1) {
      [0]=>
      float(1.2345678901235E+19)
    }
    array(1) {
      [0]=>
      string(20) "12345678901234567890"
    }
    object(stdClass)#1 (1) {
      ["num"]=>
      float(1.2345678901235E+19)
    }
    object(stdClass)#2 (1) {
      ["num"]=>
      string(20) "12345678901234567890"
    }
    

    This should be fixed soon, but for now I just wanted to update my answer to reflect this new information.

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

Sidebar

Related Questions

I have to fix a typical memory leak, Problem is like that : typedef
The problem I'm running into the typical virtual-directory dilemma in that you have some
I have come across a typical problem and it seems strange to me. Details
I've got a web application where I have the typical problem that it requires
I have this typical problem with select. First let me make it clear that
OK, typical problem: I have a table with 7884 of records (for now—but there
I have typical web application based on PHP, HTML, and javascript. From an HTML
I have a typical enterprise/business application that I am developing that includes orders, salespersons,
I have a typical dev scenario: I have a SQL 2008 database that I
I have a typical form_for for registering user. But in the end I would

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.