Home >php教程 >php手册 >PHP判断文章里是否有图片的简单方法,

PHP判断文章里是否有图片的简单方法,

WBOY
WBOYOriginal
2016-06-13 09:28:161042browse

PHP判断文章里是否有图片的简单方法,

本文的PHP程序用来判断文章里是否包含有图片,其主要实现思路就是用preg_match来检查内容里是否有匹配的“PHP判断文章里是否有图片的简单方法, 废话少说,下面是主要实现代码:

$url="http://XXXXX/article/012.html";
$content=file_get_contents($url); //读取文章页面源代码
if(preg_match("/<img .* alt="PHP判断文章里是否有图片的简单方法," >/",$content)){ //进行正则匹配判断是否有图片
  echo "检测到图片";
}else{
  echo "未发现图片";
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn