W zależności od tego co zostało wrzucone do funkcji, trzeba utworzyć obiekt innej klasy... czy jest na to inny sposób niż poza eval?
np.
$klasa='xxx'; $obiekt=new $klasa($parametr1, $parametr2);
pozdrawiam,
k.
<?php class A { public function __construct() { } public function b() { } } function loadWithConstructor($sName) { $ref = new ReflectionClass($sName); $class = $ref -> newInstance(); $class -> b(); } function loadWithoutConstructor($sName) { $ref = new ReflectionClass($sName); $inst = $ref->newInstanceWithoutConstructor(); $inst -> b(); } loadWithConstructor('A'); loadWithoutConstructor('A');
<?php class A { public function __construct() { } public function b() { } } function loadWithConstructor($sName) { $ref = new ReflectionClass($sName); $class = $ref -> newInstance(); $class -> b(); } function loadWithoutConstructor($sName) { $ref = new ReflectionClass($sName); $inst = $ref->newInstanceWithoutConstructor(); $inst -> b(); } loadWithConstructor('A'); loadWithoutConstructor('A');