Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.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意外的“意外”:&引用;在webcrawler示例的第3行_Php_Wamp - Fatal编程技术网

PHP意外的“意外”:&引用;在webcrawler示例的第3行

PHP意外的“意外”:&引用;在webcrawler示例的第3行,php,wamp,Php,Wamp,我正在研究关于的第二个示例。这是: <?php include_once('simple_html_dom.php'); $target_url = “http://www.tokyobit.com/”; $html = new simple_html_dom(); $html->load_file($target_url); foreach($html->find(‘a’) as $link){ echo $link->href.”<br />”; } ?&

我正在研究关于的第二个示例。这是:

<?php
include_once('simple_html_dom.php');
$target_url = “http://www.tokyobit.com/”;
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find(‘a’) as $link){
echo $link->href.”<br />”;
}
?>
(该文件存储在文件夹爬虫中。有人能告诉我这是为什么吗?我几乎只是从网站上复制和粘贴,前面的示例起了作用。有一条评论也有同样的问题,但回答不太好

我正在使用最新版本的WAMP服务器

谢谢!

将第3行更改为

$target_url = "http://www.tokyobit.com/";
“与”

将第3行更改为

$target_url = "http://www.tokyobit.com/";

“与“

您需要使用”或“而不是”!

您需要使用”或“而不是”!

在将文本(在您的示例URL中)声明为变量时,您必须使用单引号或双引号,而不是撇号。以上答案是正确的,只是为了添加一个解释。 PHP看不到

$target_url=“”

它将//视为文本,并在同一行中注释掉后面的所有内容。 换句话说,PHP将您的代码视为


$target_url=“http:

将文本(在您的示例url中)声明为变量时,必须使用单引号或双引号,而不是撇号。上面的答案是正确的,只是为了添加一个解释。 PHP看不到

$target_url=“”

它将//视为文本,并在同一行中注释掉后面的所有内容。 换句话说,PHP将您的代码视为


$target\u url=“http:

您还可以将第3行更改为:

$target_url = 'http://www.tokyobit.com';

也可以使用单引号(“..”)。

您还可以将第3行更改为:

$target_url = 'http://www.tokyobit.com';

也可以使用单引号(“..”)。

博客将常规引号转换为特殊引号字符
&
&
,。@TimCooper总是想知道,如何键入“(特殊)而不是“(常规)博客将常规引号转换为
&
'
对于特殊的引号字符
&
@TimCooper总是想知道,你如何键入“(特殊的)而不是“(常规的)非常棒的解释,真的很难看到。谢谢!非常棒的解释,真的很难看到。谢谢!