Bug #74480 [Opn->Nab]: Cast error from String to Int
| From: | daverandom@php.net | Date: | Thu, 20 Apr 2017 14:41:23 +0000 |
| Subject: | Bug #74480 [Opn->Nab]: Cast error from String to Int | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208682@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74480&edit=1
ID: 74480
Updated by: daverandom@php.net
Reported by: philipp dot kremer at prolead-technologies dot de
Summary: Cast error from String to Int
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Windows 10
PHP Version: 7.1.4
Block user comment: N
Private report: N
New Comment:
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
(int) casts explicitly cast to the integer data type.
The expected behaviour in this case is that the result will be an integer, a floating point result
would be extremely unexpected and cause serious problems for many use cases.
It could possibly be argued that an overflow here should produce an exception, however that is
beyond the scope of a simple bug report as this would have far reaching and likely controversial
implications.
Previous Comments:
------------------------------------------------------------------------
[2017-04-20 14:36:39] philipp dot kremer at prolead-technologies dot de
Description:
------------
Type cast from String to Int are not working correctly.
System windows 10 64bit
PHP 7.1.4 32bit
> php -v
PHP 7.1.4 (cli) (built: Apr 11 2017 20:07:48) ( NTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
> php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
filter
gettext
hash
iconv
imap
intl
json
libxml
mbstring
mcrypt
mysqlnd
openssl
pcre
PDO
pdo_mysql
Phar
readline
Reflection
session
shmop
SimpleXML
soap
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
Test script:
---------------
<?php
$mandant_id = "2147483647";
var_dump($mandant_id, (int)$mandant_id);
$mandant_id = "122994595930";
var_dump($mandant_id, (int)$mandant_id);
Expected result:
----------------
string(10) "2147483647"
int(2147483647)
string(12) "122994595930"
int(122994595930)
or
string(10) "2147483647"
int(2147483647)
string(12) "122994595930"
float(122994595930)
Actual result:
--------------
string(10) "2147483647"
int(2147483647)
string(12) "122994595930"
int(2147483647)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74480&edit=1