Php 将变量传递到文件';不能在简单的DOM中工作

Php 将变量传递到文件';不能在简单的DOM中工作,php,simple-html-dom,Php,Simple Html Dom,我这里有一个描述问题的代码, 我需要在我的变量处运行file_get_html(), 有效参数必须具有“” 我的变量开始于domain only->add the http://和/,但在您可以看到它不起作用,它结束时给出: Warning: file_get_contents('http://google.com/'): failed to open stream: Invalid argument ... simple_html_dom.php on line 75 这是密码

我这里有一个描述问题的代码, 我需要在我的变量处运行file_get_html(), 有效参数必须具有“” 我的变量开始于domain only->add the http://和/,但在您可以看到它不起作用,它结束时给出:

Warning: file_get_contents('http://google.com/'): failed to open stream: Invalid argument ... simple_html_dom.php on line 75
这是密码

        require_once('/simplehtmldom_1_5/simple_html_dom.php');
        $a = 'google.com';                              //from domain only: google.com
        $b = "'http://" . $a . "/'";                    //then, modify to have this form: http://google.com/
        //$html = file_get_html($b);                    //this thing doesn't work
        $html = file_get_html('http://google.com/');    // but this thing works

在代码中,
$b
的最终内容包含单引号,如果处理变量,则不需要单引号

更改此行以删除单引号

 $b = "'http://" . $a . "/'";  
       ^                  ^  Remove these.

在代码中,
$b
的最终内容包含单引号,如果处理变量,则不需要单引号

更改此行以删除单引号

 $b = "'http://" . $a . "/'";  
       ^                  ^  Remove these.

我不明白为什么我必须删除它,但是的,它的工作,谢谢老兄!你是最棒的。我不明白为什么我必须移除它,但它确实有效,谢谢你!你是最棒的。