php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8816 cross subscript object variable access
Submitted: 2001-01-19 22:15 UTC Modified: 2001-04-10 09:49 UTC
From: tenshi at cinter dot de Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.4 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 !
Your email address:
MUST BE VALID
Solve the problem:
32 - 20 = ?
Subscribe to this entry?

 
 [2001-01-19 22:15 UTC] tenshi at cinter dot de
I today found out a strange thing about the PHP4 object/variable handling that I can not understand.

My main script first clones a provider class and stores the new object into $MAINPROV;

Then it includes two files that give back two elements of the page.

My provider class has some subclasses. These shall be loaded on demand with functions like getFooProvider(). Theese functions test via <pre>is_object($this->FOO)</pre> if the class is already loaded. If not it includes the file containing the class definition and spawns <pre>$this->FOO = new foo($this)</pre>.

Now listen to this: If I use the load-function in the main script all works fine. But if the class is loaded from one of the subclasses (into the main provider class object that is a variable in the main script) it cannot be accessed in the other subscript, the second element. This causes the foo-class-file to be reloaded and throws out an error message because the class is already defined.

If anybody can help, it would be very very sad if I had to workaround pre-loading every subclass that can be used on this page, because I wanted to make it dynamically load the classes. Thanks!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-20 01:15 UTC] andre@php.net
Please provide a reduced code fragment (<15 lines) producing
this behaviour.
Put no database queries etc. in it and rely on no external
files/functions to ensure that we can reproduce it easily
unless the problem is not directly related to some db (or
similar) function.
 [2001-04-10 09:49 UTC] sniper@php.net
No feedback. If this happens with soon to be released PHP 4.0.5 too, reopen this bug report with a short script 
that can be used to reproduce this.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 06:01:30 2024 UTC