Home > Article > Backend Development > A simple way to determine whether there are images in an article using PHP_PHP Tutorial
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";
}