Poniższy kod działa poprawnie.Jak korzystać z metody call_user_func dla metody klasy statycznej?
LibraryTests::TestGetServer();
Pobierz wachlarz funkcji w LibraryTests i uruchomić je:
$methods = get_class_methods('LibraryTests');
foreach ($methods as $method) {
call_user_func('LibraryTests::' . $method . '()');
}
ten zgłasza błąd: Warning: call_user_func(LibraryTests::TestGetServer()) [function.call-user-func]: First argument is expected to be a valid callback
Oto klasa, który jest nazywany:
class LibraryTests extends TestUnit {
function TestGetServer() {
TestUnit::AssertEqual(GetServer(), "localhost/");
}
.
.
.
Jak naprawić?
Praca w PHP 5.2.8.
Nie dodawaj '()' jeśli funkcja nie ma parametrów – m13r