php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21008 When initialising an undeclared instance variable no error is shown
Submitted: 2002-12-14 06:03 UTC Modified: 2002-12-14 06:07 UTC
Votes:3
Avg. Score:2.3 ± 0.9
Reproduced:0 of 1 (0.0%)
From: jan_willem_maarse at hotmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 - 14 = ?
Subscribe to this entry?

 
 [2002-12-14 06:03 UTC] jan_willem_maarse at hotmail dot 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');

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-14 06:07 UTC] derick@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC