Possible Duplicate:
Php dynamic class construction
How i can create an object from class by its name?
Like this
$name = "test";
$test = "text from var";
print ${$name};
<?php
class SomeClass {
public function __construct() {
echo "construct SomeClass";
}
}
$className = 'SomeClass';
$obj = new $className();
Output: construct SomeClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With