I have an html iframe code and I want to get the href value of the first a tag. I have this php code
<?php
$iframe_input=$_GET["code"];
$doc_url = new DOMDocument();
@$doc_url->loadHTML($iframe_input);
$iframe_links = $doc_url->getElementsByTagName('a');
$iframe_link = $iframe_links[0]->getAttribute('href');
echo $iframe_link;
?>
When I run it locally on xampp everything is ok. But when I run it on a nginx webserver (digitalocean), I get an HTTP 500.
PHP message: PHP Fatal error: Cannot use object of type DOMNodeList as array
FYI If I remove$iframe_link = $iframe_links[0]->getAttribute('href');
, it doesn't return an error.