php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23403 Negative integer default value becoming zero
Submitted: 2003-04-29 07:03 UTC Modified: 2003-04-29 10:37 UTC
From: php at bicou dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.2RC2 OS: Win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 14 = ?
Subscribe to this entry?

 
 [2003-04-29 07:03 UTC] php at bicou dot com
Property with a negative integer default value is not correctly initialized :

<?php

class TestNeg {
	var $v = -10;
}

$tn = new TestNeg;
echo $tn->v;

?>

outputs '0' instead of '-10'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-29 10:34 UTC] sniper@php.net
You must have done something wrong, that works just fine
here. Not bug.

 [2003-04-29 10:37 UTC] wez@php.net
Possibly related to #23395, which has just been fixed.
 [2003-05-01 21:52 UTC] yzcai at ustc dot edu
A function with negative integer default value would have the same problem.
<?php
function test($var = -1)
{
	echo $var;
}
test();
?>
And the output is 0.
not bug?
 [2003-05-01 22:04 UTC] yzcai at ustc dot edu
well,i've got the lastest stable package from snaps.php.net and the problem has been fixed.yeah,not bug now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 20:01:30 2024 UTC