>  기사  >  백엔드 개발  >  请教下面php问什么会出错

请教下面php问什么会出错

WBOY
WBOY원래의
2016-06-13 12:08:24693검색

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

preg_match_all('/\请教下面php问什么会出错/i',$str,$images);

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") [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") [function.file-get-contents]: failed to open stream: Invalid argument in C:\AppServ\www\image.php on line 9
------解决思路----------------------
多个一对 "   改成

preg_match_all('/\请教下面php问什么会出错/i',$str,$images);



성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.