2010-08-09 64 views
0

嗨,我是使用下面的代碼:寫一個文件中的內容到另一個PHP的file_get_contents錯誤

$page = file_get_contents('myPage.php?id='.$_GET['id']); 
$file = 'temp/form_'.$_GET['id'].'.html'; 
file_put_contents($page, $file); 

但我不斷收到以下錯誤

Warning: file_get_contents(myPage.php?id=9) [function.file-get-contents]: 
Invalid argument in C:\Program Files\etc\etc.. 

Warning: file_put_contents() [function.file-put-contents]: Filename 
Filename cannot be empty in C:\Program Files\etc\etc.. 

任何人都知道什麼可能會導致這些錯誤

感謝

rifki

+0

你是杜蒙再次廢話 – 2010-08-09 17:00:03

+0

請注意,你**真**不應該傾銷'$ _GET的內容'變量到'file_get_contents'調用... – 2010-08-09 17:37:01

回答

1

你有爭論的後傾file_put_contents。嘗試切換它們如下:

file_put_contents($file, $page); 

編輯:

$page = include 'myPage.php'; 
+0

謝謝修復第二個錯誤,但仍然有第一個說明我有一個無效的參數,任何想法? – Rifki 2010-08-09 17:06:38

+0

'file_get_contents'以字符串的形式讀入文件,並不會將其作爲PHP進行處理。嘗試使用包含代替。編輯我的回覆以添加額外的代碼。 – Joseph 2010-08-09 17:34:17

0

我認爲你嘗試讀取'myPage.php?id='.$_GET['id']頁面的內容,並將其寫入到一個HTML文件。 那就試試這個:

$page = file_get_contents($your_domain . $slash_if_necessary . 'myPage.php?id='.$_GET['id']); 
$file = 'temp/form_'.$_GET['id'].'.html'; 
file_put_contents($page, $file); 
0

給使用HTTP的完整路徑:/

爲了解決第一個錯誤的變量聲明更改爲/