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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 17:01:33 2024 UTC