H
H
Hazrat Hajikerimov2014-10-08 15:32:57
PHP
Hazrat Hajikerimov, 2014-10-08 15:32:57

How to refer to a static method, having only the name of the class in the variable?

$modules = array(
       'catalog', 'shop', 'user', 'news', 'page', 'mail'
);
if(in_array(Router::$page,$modules)){
      include self::PATH.Router::$page.'/index.php';
      // как обратится к статическому методу, имея подключенный класс и название класса в Router::$page?
}else{
      include self::PATH."show/index.php";
}

In this code, the class is connected include self::PATH.Router::$page.'/index.php';
. Next, having the class name $modules, it will turn to the static method, how to do this?
Refused
swith(Router::$page){
     case "main"
            include 'class/main/index.php';
            main::show();
      break;

The condition is too long

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2014-10-08
@hazratgs

call_user_func, the manual describes the appropriate calling methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question