Esempio n. 1
0
    // make 方法用于生产实例
    public function make($b, $parameters = [])
    {
        if (isset($this->instances[$b])) {
            return $this->instances[$b];
        }
        array_unshift($parameters, $this);
        return call_user_func_array($this->binds[$b], $parameters);
    }
}
$app = new container();
$app->bind("cache", function ($index) {
    $caches = ['redis', 'memache'];
    return new $cache[$index]();
});
$app->make("cache", [1]);
$app->bind("msg", "uooki/msg/apmsg");
$app->make("msg");
exit;
class test
{
    protected $binds;
    public static function meth1()
    {
        $a = self::meth2();
        echo $a . '\\n';
        echo " i am static public function:meth1!";
    }
    private static function meth2()
    {
        return " i am  private  function:meth2 !";