要在YII工程的目錄裡面增加檔案,與基本的PHP負載檔案方式一致。比如,要在protected增加一個function.php檔案。那麼,在index.php中間,直接:
require_once('./protected/function.php');
但是使用
Yii::app()->request->baseUrl./protected/function.php。就會報出找不到檔案的錯誤。比如:
require_once(Yii::app()->request->baseUrl.'/protected/function.php');
請問為什麼第二種方式會出現找不到檔案呢?
錯誤是:
require_once(/manyouren/2/protected/function.php): failed to open stream: No such file or directory
回複內容:
要在YII工程的目錄裡面增加檔案,與基本的PHP負載檔案方式一致。比如,要在protected增加一個function.php檔案。那麼,在index.php中間,直接:
require_once('./protected/function.php');
但是使用Yii::app()->request->baseUrl./protected/function.php。就會報出找不到檔案的錯誤。比如:
require_once(Yii::app()->request->baseUrl.'/protected/function.php');
請問為什麼第二種方式會出現找不到檔案呢?
錯誤是:
require_once(/manyouren/2/protected/function.php): failed to open stream: No such file or directory
很多方法,這裡就不粘貼了,具體請查看
http://zccst.iteye.com/blog/1233367