php - how to do $class::function($data); -


I have several classes that have the same function, depending on different variables, at different times calls

What do I need

  $ class = 'test'; $ Return = $ class :: do_something ();  

But I get a parse error: parse error, unpredictable t_paamayim_nekudotayim

which looks about it unexpected ::.


Update:
, it works directly on my local host, but why not on my Prod Server? What is a php_ini setting?

You have a dynamic call class function.

Similar:

  call_user_func ($ class. ':: do_something'); For the functions of the parameter, you would like to use it: 

  call_user_func_array ($ class. ':: do_something', array ($ data)) ; To answer your second question,  The ability to call static methods on variable class names was added only to PHP 5.3.0, so your code works on one that the server puts an error on each other. 


Comments