php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24388 Redefining class properties
Submitted: 2003-06-29 12:52 UTC Modified: 2003-06-29 13:32 UTC
From: xbite at exonium dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.2 OS: Linux - Slackware 8.0
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: xbite at exonium dot net
New email:
PHP Version: OS:

 

 [2003-06-29 12:52 UTC] xbite at exonium dot net
Description:
------------
If you redefine class property, you don't get any errors.

Reproduce code:
---------------
class Class {
  var $property = "some value";
  var $property = "some other value";
}

Expected result:
----------------
PHP should generate an error.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-29 13:00 UTC] derick@php.net
It does:
[derick@kossu derick]$ php-4.3.3RC1 
<?php
class Class {
  var $property = "some value";
  var $property = "some other value";
}
?>
PHP Parse error:  parse error, expecting `T_STRING' in - on line 2

 [2003-06-29 13:08 UTC] xbite at exonium dot net
sorry for bad code -- not "class Class", try something else insted of "Class".
 [2003-06-29 13:32 UTC] derick@php.net
[derick@kossu derick]$ php
<?php
class F {
  var $property = "some value";
  var $property = "some other value";
}
?>
PHP Fatal error:  Cannot redeclare f::$property in - on line 4

As you see this works fine (with PHP-5.0.0dev).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 21:01:27 2025 UTC