jcadima
7/25/2017 - 8:43 PM

call_user_func_array for classes with Namespaces

call_user_func_array for classes with Namespaces

https://durak.org/sean/pubs/software/php-5.4.6/function.call-user-func-array.html


<?php

namespace Foobar;

class Foo {
    static public function test($name) {
        print "Hello {$name}!\n";
    }
}

// As of PHP 5.3.0
call_user_func_array(__NAMESPACE__ .'\Foo::test', array('Hannes'));

// As of PHP 5.3.0
call_user_func_array(array(__NAMESPACE__ .'\Foo', 'test'), array('Philip'));


The above example will output something similar to:

Hello Hannes!
Hello Philip!