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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at jort dot net
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 20:03:34 2021 UTC