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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 15:01:33 2024 UTC