Home  >  Article  >  Backend Development  >  A simple way to determine whether there are images in an article using PHP_PHP Tutorial

A simple way to determine whether there are images in an article using PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:58815browse

A simple method for PHP to determine whether there are pictures in an article

This article mainly introduces the method for PHP to determine whether there are pictures in an article. It is a very practical function. Friends who need it can For reference

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 a matching "

" in the content.

Stop talking nonsense, here is the main implementation code:

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

 $content=file_get_contents($url); //Read article page source code

 if(preg_match("/

echo "Picture detected";

 }else{

echo "No image found";

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852815.htmlTechArticleA simple method for PHP to determine whether there are pictures in an article. This article mainly introduces PHP to determine whether there are pictures in an article. Method, very practical function, friends who need it can refer to the PH of this article...
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