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
 [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: Thu Mar 28 09:01:26 2024 UTC