php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29884 incorrect intval return
Submitted: 2004-08-29 22:57 UTC Modified: 2004-08-30 08:11 UTC
From: babansky at cox dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.7 OS: Mandrake 9.2
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: babansky at cox dot net
New email:
PHP Version: OS:

 

 [2004-08-29 22:57 UTC] babansky at cox dot net
Description:
------------
if you try to do intval on the following string:
$str_value='09123456789';

you receive the following: 2147483647



Reproduce code:
---------------
	$str_value='09123456789';

	echo "str_value -> $str_value<BR>";

	$num_value=intval($str_value);
	echo "num_value -> $num_value<BR>";


Expected result:
----------------
$num_value = 9123456789

Actual result:
--------------
$num_value=2147483647

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-30 06:49 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Read about octal numbers and type-juggling here: http://www.php.net/manual/en/language.types.integer.php
 [2004-08-30 08:11 UTC] babansky at cox dot net
Yet you'd expect intval to return decimal number and not octal (!!). The default intval base is 10.

Try the same script with $str_value='0912345678';
and $str_value='09123456789' to see the difference;
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 02:01:26 2025 UTC