引入类thinkphp5.0

/application/index/controller/Test.php


namespace app\index\controller;  当前命名空间名称
use think\Controller;
use app\common\jssdk\getjsapiticket;    引入
             控制器\文件夹\类名
class Test extends Controller
{
    public function test()
       {
          $pinyin = new getjsapiticket();    //实例化类名
          var_dump($pinyin->nihao());
       }
}

/application/common/jssdk/getjsapiticket.php


namespace app\common\jssdk;//文件夹名称func
use Think\Controller;

Class getjsapiticket extends Controller{ //类名getjsapiticket跟文件名一致
 public function nihao(){//方法名nihao
  echo 123;
 }

}
?>

你可能感兴趣的:(引入类thinkphp5.0)