好了,網站的結構很簡單:沒有這樣的文件或目錄(路徑誤差)
site.com
- '
config
' 文件夾- 的config.php
- 塞薩爾.php
- '
login
'文件夾- 的index.php
- 的index.php
的config.php:
include_once '../config/cesar.php';
在site.com/index.php
:
Warning: include_once(../config/cesar.php): failed to open stream: No such file or directory
在site.com/login/index.php
一切都OK。
如果我將刪除一個點(./config/cesar.php),主要指標將成爲確定和登錄頁面將得到錯誤。 如何使兩個代碼工作?
取代像
你的路** ** ..意味着我們要返回到目錄中。既然** config.php和cesar.php **都在同一個文件夾中,不需要放** .. **,只需調用include_once'/config/cesar.php';** –
@CamiloGo,用/config/cesar.php在登錄頁面上得到錯誤。 –
** include_once'../config/cesar.php';**這是隻有'登錄'文件夾,因爲你正在訪問index.php和cesar.php是在另一個文件夾。它需要上去目錄找到它的文件夾。 –