本文實例講述了thinkphp5框架實現的自定義擴展類操作。分享給大家供大家參考,具體如下:
1.在extend目錄下新建要定義的擴展類:如下圖所示
2.定義擴展類的內容
<?php namespace org; /** * */ class Auth { public function __construct() { # code... } public function xx() { echo 'xxxxxxxxxxxxxx'; } }
3.在控制器中調用自定義的擴展類
<?phpnamespace appindexcontroller;use thinkController;use orgAuth; //引入擴展類class Index extends Controller{ public function index() { $a = new Auth(); $a->xx(); }}
4.結果如下
xxxxxxxxxxxxxx
希望本文所述對大家基于ThinkPHP框架的PHP程序設計有所幫助。
新聞熱點
疑難解答
圖片精選