When I run the following PHP code:
<?php
$start = "https://en.wikipedia.org";
function follow_links($url) {
$doc = new DOMDocument();
$doc->loadHTML(file_get_contents($url));
$linklist = $doc->getElementsByTagName("a");
foreach ($linklist = $link) {
echo $link->getAttribute("href")."\n";
}
}
follow_links($start);
Error:
Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\test.php on line 12
What am I doing wrong, because I swear that I have closed all brackets correctly.