本文介绍了无法打开流:无效的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此代码中:
$path = "C:\NucServ\www\vv\static\arrays\news.php";
$fp = fopen($path, "w");
if(fwrite($fp=fopen($path,"w"),$text))
{
echo "ok";
}
fclose($fp);
我收到此错误消息:
failed to open stream: Invalid argument
我的代码有什么问题?
推荐答案
PHP将您的反斜杠转换为特殊字符.例如,...arrays\news.php
变成
Your backslashes is converted into special chars by PHP. For instance, ...arrays\news.php
gets turned into
...arrays
ews.php
您应该这样逃避它们:
$path = "C:\\NucServ\\www\\vv\\static\\arrays\\news.php";
或使用单打,如下所示:
Or use singles, like this:
$path = 'C:\NucServ\www\vv\static\arrays\news.php';
此外,您的if
被弄乱了.您不应该再次fopen
该文件.只需使用您已经拥有的$fp
.
Also, your if
is messed up. You shouldn't fopen
the file again. Just use your $fp
which you already have.
这篇关于无法打开流:无效的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!