如何使用Php检查网站是否启用了Amp
是否有一种常规方法来检查是否为URL启用了AMP 我目前使用Curl来获取HTML。 之后我该怎么办如何使用Php检查网站是否启用了Amp,php,amp-html,Php,Amp Html,是否有一种常规方法来检查是否为URL启用了AMP 我目前使用Curl来获取HTML。 之后我该怎么办 $html; if(AMP is Enabled) echo "You are using AMP in Mobile Version"; else echo "You are not using AMP in Mobile Version"; 是的,你可以这样做 非AMP页面包含 <link rel="amphtml" href="https://www.example
$html;
if(AMP is Enabled)
echo "You are using AMP in Mobile Version";
else
echo "You are not using AMP in Mobile Version";
是的,你可以这样做 非AMP页面包含
<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">
$dom = new DOMDocument();
@$dom->loadHTML($html);
$nodes = $dom->getElementsByTagName('link');
foreach ($nodes as $node)
{
if ($node->getAttribute('rel') === 'amphtml')
{
echo($node->getAttribute('href'));
/* amp page found do your logic */
}
}