php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35950 Integer conversion and hex values
Submitted: 2006-01-09 20:36 UTC Modified: 2015-02-08 10:22 UTC
From: tomas_matousek at hotmail dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: * OS: *
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: tomas_matousek at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-01-09 20:36 UTC] tomas_matousek at hotmail dot com
Description:
------------
Why is (int) conversion ignoring hexadecimals if all other operation using integer conversions convert them?
I think (int) conversion should also convert hexadecimals to be consistent with others.

Reproduce code:
---------------
$a = "0x10";

var_dump((int)$a,$a * 1,$a == "16");

Expected result:
----------------
int(16)
int(16)
int(17)
bool(true)

Actual result:
--------------
int(0)
int(16)
int(17)
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-09 20:37 UTC] tomas_matousek at hotmail dot com
int(17) should be there, of course.
 [2014-05-01 02:13 UTC] levim@php.net
-Package: Feature/Change Request +Package: *General Issues -Operating System: WinXP +Operating System: Irrelevant -PHP Version: 5.1.2RC1 +PHP Version: 5.1.2
 [2015-01-09 00:02 UTC] ajf@php.net
-Operating System: Irrelevant +Operating System: * -PHP Version: 5.1.2 +PHP Version: *
 [2015-01-09 00:02 UTC] ajf@php.net
This would be fixed by this RFC (it removes hex support): https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
 [2015-01-09 16:02 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2015-02-08 10:22 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2015-02-08 10:22 UTC] nikic@php.net
Fixed in PHP 7, by removing hex-string support in the cases where it existed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC