[SOLVED] create obj by name
Posted: Mon Jul 26, 2004 9:51 am
Hi
Depending on a $_GET parameter, called module, I get to know which php file i have to include and execute. Every file contains a special module class to work with. Since the $_GET param is of the same name as the include file I can easily include it by
The class in the file has the same name also but how can I dynamically instantiate a PHP class with just knowing its name ?
will not work (of course)
Any Idea , how to instantiate objects by just knowing their name ?
regards _yak
Depending on a $_GET parameter, called module, I get to know which php file i have to include and execute. Every file contains a special module class to work with. Since the $_GET param is of the same name as the include file I can easily include it by
Code: Select all
<?php
require($_GET['module'].".php")
?>Code: Select all
<?php
$module = new $_GET['module'].".php";
$_GET['module']->doMethod();
?>Any Idea , how to instantiate objects by just knowing their name ?
regards _yak