Is there a general way to check if AMP is enabled for an URL?
I currently use Curl to get HTML.
What should I do after?
$html;
if(AMP is Enabled)
echo "You are using AMP in Mobile Version";
else
echo "You are not using AMP in Mobile Version";
Yes you can do like this
Non AMP page contain
<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">
Assuming that you have the content in $html;
PHP CODE
$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 */
}
}