开发者

failed to open stream: Invalid argument

开发者 https://www.devze.com 2022-12-22 21:21 出处:网络
In this code : $path = \"C:\\NucServ\\www\\vv\\static\\arrays\\news.php\"; $fp = fopen($path, \"w\"); if(fwrite($fp开发者_如何学Go=fopen($path,\"w\"),$text))

In this code :

$path = "C:\NucServ\www\vv\static\arrays\news.php";
  $fp = fopen($path, "w");
  if(fwrite($fp开发者_如何学Go=fopen($path,"w"),$text))
  {
    echo "ok";
  }
  fclose($fp);

I have this error message:

failed to open stream: Invalid argument

What is wrong in my code?


Your backslashes is converted into special chars by PHP. For instance, ...arrays\news.php gets turned into

   ...arrays
   ews.php

You should escape them like this:

$path = "C:\\NucServ\\www\\vv\\static\\arrays\\news.php"; 

Or use singles, like this:

$path = 'C:\NucServ\www\vv\static\arrays\news.php'; 

Also, your if is messed up. You shouldn't fopen the file again. Just use your $fp which you already have.


  1. path error:

    $path = 'C:/NucServ/www/vv/static/arrays/news.php'; 
    
  2. file lock:

    user file_get_contents replace fopen
    
0

精彩评论

暂无评论...
验证码 换一张
取 消