|
Posted by "Richard Lynch" on 10/23/05 04:11
On Sat, October 22, 2005 5:56 pm, Todd Nine wrote:
> I have need to dynamically load some classes. I have created an
> abstract class that defines a function. Note that I'm using PHP 4 so
> abstract is not enforced. 3rd party plugins will then implement this
> interface. Users will upload their plugins via a web interface. After
> I save the php class file to the directory ./plugins, I will need to
> load it later. Basically I need to do something like.
Am I to understand that users are uploading PHP code you're going to
execute?...
Sure hope you trust them :-)
Anyway, if you can force them to use that __autoload() thingie (see
the manual) then you're all set. Their class name matches their
filename and it just works like Magic when you make a new $whatever.
Or, the other way around, you know what to make a new of because it
matches the filename.
You need unique filenames anyway, so that keeps your class names
unique, unless somebody crams some "helper" class into their file.
May want to have a "rule" that additional classes in a file MUST have
the filename and underscore as the first part of any helper classes,
just to avoid collisions.
That would probably be the "right way"
If your version of PHP does not support __autoload, check in PECL and
PEAR and in user-contributed notes for work-arounds and
backward-compatible functions.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|