2015-09-05 24 views
1

我有一個phpUnit的問題。不能要求phpUnit中的父目錄

每當我嘗試打開使用需要一個文件(或任何其他類似功能),這是不是在同一個目錄或子目錄作爲測試文件本身,PHPUnit的引發此錯誤:

Warning: include_once Failed opening "C:\....." for inclusion (include path = '.;C:\xampp\php\PEAR')

可有人告訴我做錯了什麼?謝謝

+0

你知道,如果一個路徑以斜槓開始,PHP將它解釋爲從本地磁盤根目錄開始,而不是從服務器的WWW根?也許這就是問題所在。如果沒有,發佈代碼。 –

回答

2

嘗試使用真實路徑和目錄名來獲得完整的路徑

# ../myfolder/file.php 
$path = realpath(dirname(dirname(__FILE__)))."/myfolder/file.php" 

# ./file.php 
$path = realpath(dirname(__FILE__))."/file.php" 

# ../file.php 
$path = realpath(dirname(dirname(__FILE__)))."/file.php" 

# ../../file.php 
$path = realpath(dirname(dirname(dirname(__FILE__))))."/file.php"