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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC