I am having trouble with this piece of code below. Whenever I run this file from browser it shows me the same code load_file($target_url); foreach($html->find(‘a’) as $link){ echo $link->href." on the browser and not the desired result. I am working on a website using xampp. Php is also properly configured.
"; } ?>
<?php
include_once('/simple.php');
$target_url = "http://www.example.com/";
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find(‘a’) as $link){
echo $link->href."<br />";
}
?>
For some reason it seems like the PHP parser interprets the -> in $html->load_file( as if it should close PHP parsing, thus showing you the rest of the code as HTML.
it interprets -> as if it was a ?>
The server is probably misconfigured, or some strange option is in effect.
Other PHP files may work fine if they do not contain -> so if not using objects
If they are allowed on your server, you could try alternative syntax:
Or ASP style syntax
Although ugly it might solve your problem