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

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

WBOY
Release: 2016-06-13 09:28:02
Original
776 people have browsed it

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

   这篇文章主要介绍了PHP判断文章里是否有图片的方法,很实用的功能,需要的朋友可以参考下

  本文的PHP程序用来判断文章里是否包含有图片,其主要实现思路就是用preg_match来检查内容里是否有匹配的“

  废话少说,下面是主要实现代码:

  $url="http://XXXXX/article/012.html";

  $content=file_get_contents($url); //读取文章页面源代码

  if(preg_match("/

  echo "检测到图片";

  }else{

  echo "未发现图片";

  }

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template