php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80011 Bug at cast type float
Submitted: 2020-08-24 09:18 UTC Modified: 2020-08-24 09:36 UTC
From: god6dog at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 7.4.9 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: god6dog at gmail dot com
New email:
PHP Version: OS:

 

 [2020-08-24 09:18 UTC] god6dog at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.http-build-query
---
float type with zero at the end is incorrectly converted

Test script:
---------------
Bug at cast type float:
php >  echo http_build_query(['foo' => 123.00]);
foo=123
php >  echo http_build_query(['foo' => 123.01]);
foo=123.01


Expected result:
----------------
php >  echo http_build_query(['foo' => 123.00]);
foo=123.00

Actual result:
--------------
php >  echo http_build_query(['foo' => 123.00]);
foo=123

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-24 09:22 UTC] god6dog at gmail dot com
-Summary: php 7.4.9 +Summary: Bug at cast type float
 [2020-08-24 09:22 UTC] god6dog at gmail dot com
Changed description
 [2020-08-24 09:36 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-08-24 09:36 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This has nothing to do with http_build_query, but is rather normal
behavior for floats[1].  If you need to preserve the two decimals,
just pass a string[2].

[1] <https://3v4l.org/FuC6Y>
[2] <https://3v4l.org/6kIsm>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC