[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] PHP dynamisk instancerering af klasser



David Bo Jensen wrote:
Jeg har mange klasser, som nedarver fra samme base klasse, og som alle har metoden "start". Klasserne er defineret i hver deres fil (ex. k1.php, k2.php, k3.php ..)

Gennem et dataopslag i en database får jeg navnet på klassen (ex. k1), der skal laves en instans af. Hvordan gør jeg så dette? og herefter kalder "start"?

$classes = array('k1', 'k2', 'k3'); foreach($classes as $classname) { $instance = new $classname; $instance->start(); }

Det mener jeg virker.

--
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  |     Visit us at: http://www.gmta.info


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-12-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *