2013-03-18 43 views
4

我的服務器上有兩個文件。 文件a.phpfile_get_contents到URL在同一臺服務器上

<?php 
die('this is my text'); 
?> 

文件b.php:

<?php 
file_get_contents('http://mysite.pl/a.php'); 
?> 

但它不工作...我不能使用file_get_contents,當文件位於同一臺服務器上,我不不知道爲什麼。 PHP信息:

allow_url_fopen: ON 
allow_url_include: OFF 

當我試圖使用從文件b.php代碼難於服務器上 - 它的工作...;/

+0

本地獲取文件時,請改用本地文件路徑。或者你是否希望'file_get_contents'的結果包含'這是我的文本'? – castis 2013-03-18 18:24:34

+0

請教關於這個主題的PHP手冊(例子#1)嘗試:http://php.net/manual/en/function.file-get-contents.php – 2013-03-18 18:24:52

+0

請定義「不工作」。有沒有錯誤信息? – helmbert 2013-03-18 18:25:16

回答

-3

您可以嘗試的相對路徑。

如果a.phpb.php是在相同的目錄中,執行:

// b.php (If a.php is in the same directory) 
file_get_contents('./a.php'); 

如果a.php處於上部目錄:

// b.php (If a.php is in an upper directory) 
file_get_contents('../a.php'); 

如果a.php是在根目錄:

// b.php (If a.php is in the root directory) 
file_get_contents('/a.php'); 
0

你可以試試usi ng 127.0.0.1,但它不能在VirtualHost上運行。

相關問題