Define a class dynamically?

Posted by Pekka on Stack Overflow See other posts from Stack Overflow or by Pekka
Published on 2010-03-16T20:10:12Z Indexed on 2010/03/16 20:11 UTC
Read the original article Hit count: 228

Filed under:
|
|

Is there a way to dynamically and conditionally create a class definition in PHP, i.e.

if (condition matches)
  include file containing class definition
else
  class myclass extends ancestor_class { .................... }

without eval()?

My background is the accepted answer to this question. I am looking for the best way to build a untouchable core library, with user-defined empty classes extending the core library if necessary.

I want to create the final class definition "on the fly" if there is no user-defined empty class for a certain ancestor class.

© Stack Overflow or respective owner

Related posts about php

Related posts about php5