Home > Backend Development > PHP Tutorial > A simple way to determine whether there are pictures in an article using PHP, _PHP tutorial

A simple way to determine whether there are pictures in an article using PHP, _PHP tutorial

WBOY
Release: 2016-07-13 10:22:08
Original
877 people have browsed it

A simple way to determine whether there are pictures in an article using PHP,

The PHP program in this article is used to determine whether the article contains images. The main implementation idea is to use preg_match to check whether there is a matching " Without further ado, here is the main implementation code:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/851355.htmlTechArticleA simple method for PHP to determine whether there are pictures in the article. The PHP program in this article is used to determine whether the article contains pictures. , the main implementation idea is to use preg_match to check whether there is...
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