无法打开流:无效的参数 [英] failed to open stream: Invalid argument

查看:109
本文介绍了无法打开流:无效的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此代码中:

$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.

这篇关于无法打开流:无效的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆