2010-08-09 75 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的完整路径:/

为了解决第一个错误的变量声明更改为/