For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > July 2007 > #42154 [Opn->Ver]: settype() change data without warning!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #42154 [Opn->Ver]: settype() change data without warning!
jani@php.net

2007-07-31, 8:00 am

ID: 42154
Updated by: jani@php.net
Reported By: tjibbe at rijpma dot org
-Status: Open
+Status: Verified
-Bug Type: *General Issues
+Bug Type: Documentation problem
Operating System: linux
PHP Version: 5.2.3
New Comment:

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...)


Previous Comments:
------------------------------------------------------------------------

[2007-07-31 09:05:02] 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


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=42154&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com