Hi,
I have a classname in a variable, and I whish to call a static method on
that class, what's the syntax for that?
I'm using PHP5.
Eg.
<?php
class Foo {
public static function bar() {
echo "Foo bar";
}
}
$class_name = 'Foo';
$foo = new $class_name(); // I can do this.
$class_name::ba r() // This is an error... "parse error, unexpected
T_PAAMAYIM_NEKU DOTAYIM"
Foo::bar() // This is how it's normally done..
?>
So what I want to do is $class_name::ba r(), is it possible and what is the
syntax?
Regards,
Peter Albertsson
I have a classname in a variable, and I whish to call a static method on
that class, what's the syntax for that?
I'm using PHP5.
Eg.
<?php
class Foo {
public static function bar() {
echo "Foo bar";
}
}
$class_name = 'Foo';
$foo = new $class_name(); // I can do this.
$class_name::ba r() // This is an error... "parse error, unexpected
T_PAAMAYIM_NEKU DOTAYIM"
Foo::bar() // This is how it's normally done..
?>
So what I want to do is $class_name::ba r(), is it possible and what is the
syntax?
Regards,
Peter Albertsson
Comment