前言(发生来源)
看到群友“老陈”发出冒泡商城的图片时,我想到能不能批量获取MRP应用,于是在一番抓包测试之后,脚本基本完成,
但是,在使用file_put_contents() 保存文件的时候,遇到了问题。
详情
一开始之这么写的:
// 存储MRP文件 $filename = 'mrp/'.$filename; file_put_contents($filename, $fileContent);
但是,出现奇怪的错误
Warning: file_put_contents() expects parameter 1 to be a valid path, string given in E:\Backup\backup document\WEB\test\index.php on line 51
所以,
path和string有什么区别????一脸懵逼。。。遂搜索之。在stackoverflow找到如下帖子:
file_put_contents() expects parameter 1 to be a valid path, string given
I got the same error before but I don’t know if this solution of mine works on your problem you need to remove the “\0” try replace it:
$cleaned = strval(str_replace("\0", "", $buttons_first));(我猜
\0是在字符串结尾。。)试着改成这样:
// 存储MRP文件
$filename = strval(str_replace("\0", "", 'mrp/'.$filename));
file_put_contents($filename, $fileContent);
成了!
—–完—–
![[记录]关于PHP中file_put_contents()的路径不能使用变量代替的解决 [记录]关于PHP中file_put_contents()的路径不能使用变量代替的解决](https://cdn.jysafe.cn/wp-content/uploads/2020/02/2020022800505350.png!water.jpg)

