phpbar.de logo

Mailinglisten-Archive

[php] Klassen Problem

[php] Klassen Problem

Ulf Wendel ulf_(at)_redsys.de
Sun, 07 May 2000 19:40:17 +0200


Wolfgang wrote:
> ${"klasse".$x[1]} = new class;

Vorsicht, Virenzüchter unterwegs.

class foo {
	function foo() {
		echo "bar<hr>";
	}
	
	function sayHello() {
		echo "Hello!<hr>";
	}
}

$x = array(emil, otto);
${"foo_".$x[1]} = new foo;

$code = sprintf('$foo_%s->sayHello();', $x[1]);
eval($code);

$class = ${"foo_$x[1]"};
$class->sayHello();

$GLOBALS["foo_$x[1]"]->sayHello();

$classes = array ( $x[1] => ${"foo_$x[1]"} );
$classes[$x[1]]->sayHello();

Ulf


php::bar PHP Wiki   -   Listenarchive