By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,062 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,062 IT Pros & Developers. It's quick & easy.

Migrating OOP php4 -> 5 - $this re-assign - Recreating an instance scope outside

P: 48
Hi, I have another problem migrating to php5.

An important piece of my "web kernel" is a system of include / require throw exceptions :

Instead of : require $x
I do : trigger_error ('INC_'.$x...)

Error_handler :
$this = $errcontext ["this"] ; //Error!!!!!
include $x ;

It allows me to decide some things, to find dinamically files, to log for debug, ... I liked very much this solution and changing that it's a lot of work.

You can require a file in the code of a class method, and the inserted code fits there transparently. So, how can I emulate this when I've changed the scope temporaly, I'm in a third function.
I have to pass the instance reference from a class method to another scope (function -> error_handler -> included file) keeping the $this reference transparently.

Any ideas?
Dec 18 '07 #1
Share this Question
Share on Google+
1 Reply

P: 48
I think I've found a possible solution with the runkit extension : runkit_method_add (using a temporary and externally created method). Like aggregate_methods in php4...

Any better solution?

Thanks anyway!
Dec 18 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.