Home > Backend Development > PHP Tutorial > PHP判断文章里是否有图片的简单方法_PHP

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

WBOY
Release: 2016-06-01 11:50:23
Original
847 people have browsed it

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template