#28240 [Opn->Bgs]: class member assigment without declaration defines new member

From: Date: Tue, 04 May 2004 07:01:25 +0000
Subject: #28240 [Opn->Bgs]: class member assigment without declaration defines new member
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-59196@lists.php.net to get a copy of this message
ID: 28240 Updated by: derick@php.net Reported By: php at jort dot net -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Win2000 Pro PHP Version: 5.0.0RC2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2004-05-04 05:51:30] phpbug at gb404 dot com It is totally normal. As far as I can remember, PHP never needed to declare a variable before using it. ------------------------------------------------------------------------ [2004-04-30 22:30:09] php at jort dot net Description: ------------ When you assign a value to a class member that was not declared the system defines a new class member. I'm not sure this is a feature or a bug. I would expect an error or at least a notice or a warning. Reproduce code: --------------- <?php class foo { function __construct() { $this->foo = "test"; } } $bar = new foo(); print $bar->foo; ?> Expected result: ---------------- Notice/Warning/Error Actual result: -------------- test ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28240&edit=1

« previous php.bugs (#59196) next »