静态代理

2019-08-19  本文已影响0人  咸鱼前端

facade

<?php


namespace app\facade;


class Test extends \think\Facade
{
    protected static function getFacadeClass()
    {
        return '\app\common\Test';
    }
}

动态方法

<?php

namespace app\common;

class Test
{
  public function hello($name)
  {
    return "Hello " . $name;
  }
}

调用

public function index($name = 'thinkphp')
{
        /**
         * 如果想静态调用一个动态方法,需要给当前的类绑定一个静态代理的类
         */
        return Test::hello('123');
}
上一篇 下一篇

猜你喜欢

热点阅读