php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23522 Negative valus in variable declaration in classes
Submitted: 2003-05-07 00:44 UTC Modified: 2003-05-07 05:56 UTC
From: wima at tiscali dot ch Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.3.2RC2 OS: Windows XP Professional
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: wima at tiscali dot ch
New email:
PHP Version: OS:

 

 [2003-05-07 00:44 UTC] wima at tiscali dot ch
Hello
This script does output 0 instead of -1. If I initialize the variable a in the constructor (the commented line) the output is correct. I'm not shure if it is a bug, but if I initialize the variable with a positive value it works correct.
Thanks for fixing this bug.
Marco
<?
$a = new myClass;
class myClass {
 var $a = -1;

 function myClass() {
  //$this->a = -1;
  echo $this->a;
 }
}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-07 03:58 UTC] moriyoshi@php.net
I got the correct result (-1) with the supplied script..
 [2003-05-07 04:24 UTC] wima at tiscali dot ch
Hm... I ever get 0. This is a mysteriously Bug...
 [2003-05-07 05:56 UTC] wez@php.net
Already fixed in CVS; try a snapshot from http://snaps.php.net
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 12:01:27 2025 UTC