Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Web爬虫显示意外的colan()的解析错误_Php - Fatal编程技术网

PHP Web爬虫显示意外的colan()的解析错误

PHP Web爬虫显示意外的colan()的解析错误,php,Php,我试图在我的xampp中执行这个基本的webcrawler php代码,但它在目标行中显示了一个类似unexpected(:)的错误 我的代码如下: <?php include_once('simple_html_dom.php'); $target_url = “http://www.websitename.com/”; $html = new simple_html_dom(); $html->load_file($target_url); foreach($html->f

我试图在我的xampp中执行这个基本的webcrawler php代码,但它在目标行中显示了一个类似
unexpected(:)的错误

我的代码如下:

<?php
include_once('simple_html_dom.php');
$target_url = “http://www.websitename.com/”;
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find(‘a’) as $link){
echo $link->href.”<br />”;
}
?>

错误指向
$target\u url=”http://www.websitename.com/";

任何建议都很有帮助。

试试以下方法:

<?php
include_once('simple_html_dom.php');
$url = "http://www.freelancer.com";
$html = new simple_html_dom();
$html->load_file($url);
foreach($html->find("a") as $link){
echo $url.$link->href."<br/>";
}
?>


您使用的是单引号和双引号(“”),而不是常规引号(“”)。很可能是由于您使用的编辑器

的缘故,您能告诉我们目标url行上出现了哪一行号错误吗?对于一个测试,只需放置include一次('simple_html_dom.php');下面是$target_url,然后告诉我输出是什么仍然是相同的错误您使用单引号和双引号(“”)而不是常规引号(“”)。很可能是因为您使用的编辑器