Page 1 of 1
creating class in runtime
Posted: Fri Jun 22, 2007 2:08 am
by zyklone
hello there.. i just want to ask..is it possible to create a CLASS in run time?
example:
$class = 'myclass';
$instance = new $class();
in which my myclass is not yet built.
Posted: Fri Jun 22, 2007 2:27 am
by Chris Corbyn
You need to use eval(), or possibly reflection if you're using PHP5.
Posted: Fri Jun 22, 2007 3:29 am
by harsha
are you trying to create a class code and dump into a php file using/by running another php script?
if that is the case then please take a look at this script:
http://wsdl2php.svn.sourceforge.net/vie ... iew=markup
it reads the SOAP (XML) schema and generates php code and writes it into new php files.
Posted: Fri Jun 22, 2007 6:39 am
by feyd
Generally speaking, if you need to dynamically create a class, there's something wrong. There should be a way to build what you want without needing to generate a new class.
Posted: Fri Jun 22, 2007 7:24 am
by Styx