php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28240 class member assigment without declaration defines new member
Submitted: 2004-04-30 22:30 UTC Modified: 2004-05-04 09:01 UTC
From: php at jort dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.0RC2 OS: Win2000 Pro
Private report: No CVE-ID: None
 [2004-04-30 22:30 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-04 05:51 UTC] 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-05-04 09:01 UTC] derick@php.net
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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC