php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42154 settype() change data without warning!
Submitted: 2007-07-31 09:05 UTC Modified: 2007-08-16 10:09 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: tjibbe at rijpma dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.3 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: tjibbe at rijpma dot org
New email:
PHP Version: OS:

 

 [2007-07-31 09:05 UTC] tjibbe at rijpma dot org
Description:
------------
The function gettype() changes your data without any notice of warning!

In the documentation it is also not mentioned that settype($var, 'int') has a max of 2147483647





Reproduce code:
---------------
<?php
error_reporting(E_ALL);
$var = '12345678901234567890';
settype($var, 'int');
echo $var;
?>

Expected result:
----------------
12345678901234567890

or 

WARNING: settype() too big integer 

Actual result:
--------------
2147483647

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-31 11:27 UTC] jani@php.net
Yes, the documentation in this needs a cleanup. I found this page better explaining what happens and when/why:

http://www.php.net/intval

The http://www.php.net/manual/en/language.types.integer.php page
requires some care too, it's too long. (split/add urls to topics, whatever...)
 [2007-08-01 12:25 UTC] tjibbe at rijpma dot org
or the Expected result should be:

1.2345678901345678e+17
 [2007-08-01 13:13 UTC] tjibbe at rijpma dot org
Sorry i'm confused with float.

1.2345678901345678e+17 isn't the same integer as 12345678901234567890.
 [2007-08-16 10:09 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Maximum value for "int" is PHP_INT_MAX."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 18:01:31 2025 UTC