• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

请问下面php问什么会出错

php 搞代码 3年前 (2022-01-23) 13次浏览 已收录 0个评论
文章目录[隐藏]

我就是想把 hao123的图片全都用正则匹配出来,然后再用file_get_contents()函数获取远程图片到字符串 然后再写入到文件达到下载的目的!但是file_get_contents()函数 不知道问什么匹配不了正则匹配回来的url,请大家帮忙解答下,非常感谢。
代码如下:
<?php
$str=file_get_contents(“http://www.hao123.com&#8221;);

preg_match_all(‘/\
foreach($images[1] as $key => $img)
{
$filename=$key.”.png”;
$imgs=file_get_contents(trim($img));
file_put_contents($filename,trim($imgs));
}

错误代码:
Warning: file_get_contents(“http://s0.hao123img.com/res/r/image/2014-10-18/3820a8ee766ece775cd098cba2706903.png&#8221;) [function.file-get-contents]: failed to open stream: Invalid argument in C:\AppServ\www\image.php on line 9
Warning: file_get_contents(“http://s0.hao123img.com/res/r/image/2014-09-29/d7ae4208f3fedc3c85d27f37c258706b.png&#8221;) [function.file-get-contents]: failed to open stream: Invalid argument in C:\AppServ\www\image.php on line 9

回复讨论(解决方案)

多个一对 ” 改成

preg_match_all(‘/\\”+(\S*)\”+.*?\>/i’,$str,$images);

多个一对 ” 改成

preg1本文来#源gaodai$ma#com搞$代*码*网

搞代gaodaima码

_match_all(‘/\\”+(\S*)\”+.*?\>/i’,$str,$images);

preg_match_all(‘/\

非常感谢啊! 我说的吗 子模式中多了个引号 非常感谢 哈哈


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:请问下面php问什么会出错

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址