ci 的控制器資料夾下開加子資料夾

2022-09-11 18:39:13 字數 631 閱讀 4716

在乙個比較大的專案中,希望controllers下再細分子資料夾。例如:controllers/pj,controllers/xxk等。

做法是:

1.在controllers下新增相關的子資料夾,例如pj。

$route['pj/(^/)(^/)'] = "pj/$1/$2";

哈哈,大功告成!

解釋在沒有修改routes.php檔案之前位址列中:localhost/ci/index.php/pj/student/index。表示要執行pj類的stdudent方法,並有乙個引數是index。這是ci預設的配置要求。所以如果你新增上面的路由規則是不會得到你想要的結果的。

修改routes.php檔案之後,即新增 $route[『pj/(^/)(^/)'] = "pj/$1/$2";這一句後。我們執行的是pj目錄下的student類的index方法。

說明
1.這是乙個正規表示式。相當於是把 pj/(^/)(^/)  用  pj/$1/$2 來代替。pj/(^/)(^/)是指位址列中的寫法。pj/$1/$2是指controllers下的子檔案pj下的$1類中的$2方法。

2.想要進一步了解()()和$1,$2到底是什麼東東。需要進一步去學習正規表示式。這裡有乙個比較好的學習位址。

查詢某資料夾下所有子資料夾內的py檔案 2

import os pylist for root,dirs,files in os.walk users qyk desktop my py for file in files if os.path.splitext file 1 py else continue root users qyk d...

C 遍歷得到指定資料夾下的所有檔案和子資料夾

1.遍歷指定資料夾下的所有檔案 directoryinfo root new directoryinfo path foreach fileinfo f in root.getfiles 遍歷資料夾下的每個檔案 2.遍歷指定資料夾下的所有檔案以及子資料夾也遍歷,引數傳入父資料夾即可 private ...

c 遍歷乙個資料夾下的所有檔案包括子資料夾

using system using system.io class listallfilesdemo catch ioexception e public static void listfiles filesysteminfo info c 中遍歷目錄下的目錄的檔案 二 1 遍歷乙個目錄下的全部...