2010-12-02 207 views
1

我不斷收到一個錯誤,當我嘗試包括SimpleTest的在我的include_path:PHP包括路徑錯誤

<? 
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(basename(dirname(__FILE__)) . '/../../')); 

include 'simpletest/autorun.php'; 

回報:

.:/usr/lib/php:/Users/kristiannissen/Documents/php 
Warning: require_once(/Users/kristiannissen/Documents/php/simpletest/arguments.php): failed to open stream: No such file or directory in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13 

Fatal error: require_once(): Failed opening required '/Users/kristiannissen/Documents/php/simpletest/arguments.php' (include_path='.:/usr/lib/php:/Users/kristiannissen/Documents/php') in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13 
+0

任何人都知道如何解決這個問題?沒有arguments.php文件,SimpleTest似乎不起作用。我從SimpleTest的PHP4版本中下載並替換了它,但它不是兼容的替換文件。 – Pythovore 2011-02-17 21:03:33

+0

成功。 SimpleTest 1.0.1適用於CakePHP 1.3.7。 – Pythovore 2011-02-17 21:48:43

回答

1

親自視圖頁面在第一次執行,如索引.php和查看頁面應始終位於您的html的根目錄中。

左右的時間內的index.php,你可以這樣做:如果你想在你的php目錄/Users/kristiannissen/Documents/php/simpletest

所以包括路徑,你應該使用dirname()去:

define("BASE_PATH",str_replace("\\","/",dirname(__FILE__))); 

所以現在BASE_PATH將等於UP目錄:

//Get an array of your include paths 
$include_parts = explode(PATH_SEPARATOR,get_include_path()); 

//Extend the paths 
$include_parts[] = dirname(dirname(BASE_PATH)); //this is ../../ 

//recompile the paths and set them 
set_include_path(implode(PATH_SEPARATOR,$include_parts)); 

這爲t他是安全的方式來完成你想要做的事情。

1

在sourceforge上有一個alpha2版本,其中arguments.php-require被註釋掉了。我想這不再需要了。