Can PHP Perform Magic Instantiation?
- by Aiden Bell
Despite PHP being a pretty poor language and ad-hoc set of libraries ... of which the mix of functions and objects, random argument orders and generally ill-thought out semantics mean constant WTF moments....
... I will admit, it is quite fun to program in and is fairly ubiquitous. (waiting for Server-side JavaScript to flesh out though)
question:
Given a class class RandomName extends CommonAppBase {} is there any way to automatically create an instance of any class extending CommonAppBase without explicitly using new?
As a rule there will only be one class definition per PHP file. And appending new RandomName() to the end of all files is something I would like to eliminate. The extending class has no constructor; only CommonAppBase's constructor is called.
Strange question, but would be nice if anyone knows a solution.
Thanks in advance,
Aiden
(btw, my PHP version is 5.3.2) Please state version restrictions with any answer.