File1:
// file1.phpnamespace Common\Model;class ArticleModel { static function save($id=0) { die('xxx'); }}
File2:
// file2namespace Admin\Controller;include('./file1.php');$model = 'ArticleModel';$call = "\\Common\\Model\\$model::save";$call(123123);
This method I tried, cannot be called.
is the static method not supported for dynamic invocation?
Or is there a different way to call?
Reply content:
File1:
// file1.phpnamespace Common\Model;class ArticleModel { static function save($id=0) { die('xxx'); }}
File2:
// file2namespace Admin\Controller;include('./file1.php');$model = 'ArticleModel';$call = "\\Common\\Model\\$model::save";$call(123123);
This method I tried, cannot be called.
is the static method not supported for dynamic invocation?
Or is there a different way to call?
namespace Admin\Controller; include('./file1.php'); $fqcn = '\\Common\\Model\\AritcleModel'; $func = 'save'; $fqcn::$func(123123);
$model = 'ArticleModel';$call = "\\Common\\Model\\{$model}";call_user_func_array(array($call, 'save'), array(123123));