Hi.
It's my first time with reflection and I'm not
very confy with it.
My goal is call a method randomly
from an other class.
<?php
error_reporting(E_ALL | E_STRICT);
class A{
public function __construct(){}
public function one(){
echo "I'm One<br />";
}
public function two(){
echo "I'm Two<br />";
}
public function three(){
echo "I'm Three<br />";
}
}
class B{
public function __construct(){}
public function testReflection(){
$a= new A();
$ref= new ReflectionClass(get_class($a));
$methods= $ref->getMethods();
array_shift($methods);
shuffle($methods);
call_user_func(array($a, $methods[0]->name));
}
}
$b= new B();
$b->testReflection();
?>
I'm wondering is it the right way ? :o