#21008 [Opn->]: When initialising an undeclared instance variable no error is shown
| From: | derick@php.net | Date: | Sat, 14 Dec 2002 12:07:01 +0000 |
| Subject: | #21008 [Opn->]: When initialising an undeclared instance variable no error is shown | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27692@lists.php.net to get a copy of this message | ||
ID: 21008
Updated by: derick@php.net
Reported By: jan_willem_maarse@hotmail.com
-Status: Open
+Status: Won\'t fix
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.2.3
New Comment:
Not a bug at all, you don't need to declare any variable in PHP,
nowhere. Adding an error for this will break tons of scripts, so we're
not going to add it.
Previous Comments:
------------------------------------------------------------------------
[2002-12-14 06:03:29] jan_willem_maarse@hotmail.com
When I call a method that initializes a instance variable that isn't
declared, php doen's complain. I see this as a bug, because when I
mis-spelled an instance variabele some strange things happen. Because
when I trie to get the value of an instance variabele, I get the
old/unitialized value.
Here is some sample code:
<?
class apple
{
var $color;
function fruit($new_color) {
$this->color = $new_color;
}
function set_taste($new_taste) {
$this->taste = $new_taste;
}
}
$green_apple = new apple('green');
$green_apple->set_taste('good');
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21008&edit=1