redeclare classes dynamically

From: Date: Wed, 22 Oct 2008 09:20:24 +0000
Subject: redeclare classes dynamically
Groups: php.general 
Request: Send a blank email to php-general+get-282236@lists.php.net to get a copy of this message
i'm trying to dynamically initialize bunch of classes from different paths but with the same class and file names. while ($register->request->m != 'exit') { $controlFile = './core/' . $register->request->m . '/controller.class.php'; if (is_file($controlFile)) { require_once ($controlFile); $controller = new controller($register); } } the while loop should continue till one of those classes set 'exit' as the $register->request->m value, where it exists loop and reach the eos. but i get this fatal error.. Cannot redeclare class controller in /home/vir blah blah.. yeah, i know it's because i try to declare the same class name several times. my question is.. what is the best way to implement this? many thanks ~viraj

« previous php.general (#282236) next »