strpos
找不到>$2.99<
。我在 if 语句之前回显了$html
,我可以在其中找到>$2.99<
,但结果是 not found
.
$webpage = file_get_contents ($itunesurl);
$html = htmlspecialchars ($webpage);
echo $html;
if(strpos($html, '>$2.99<') !== FALSE) {
echo 'found';
}
else {
echo 'not found';
}
搜索$webpage
而不是$html
,因为>
和<
字符被htmlspecialchars
转换为实体。
if(strpos($webpage, '>$2.99<') !== FALSE) {
echo 'found';
}
else {
echo 'not found';
}