相关疑难解决方法(0)

Reference — What does this symbol mean in PHP?

What is this?

This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.

Why is this?

It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …

php arguments symbols operators

4314
推荐指数
21
解决办法
63万
查看次数

PHP DOMDocument :: loadHTML()[domdocument.loadhtml]:htmlParseEntityRef:实体中没有名称

我试图从某些网页获取"链接"元素.我无法弄清楚我做错了什么.我收到以下错误:

严重性:警告

消息:DOMDocument :: loadHTML()[domdocument.loadhtml]:htmlParseEntityRef:实体中没有名称,行:536

文件名:controllers/test.php

行号:34

第34行是代码中的以下内容:

      $dom->loadHTML($html);
Run Code Online (Sandbox Code Playgroud)

我的代码:

            $url = "http://www.amazon.com/";

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    if($html = curl_exec($ch)){

        // parse the html into a DOMDocument
        $dom = new DOMDocument();

        $dom->recover = true;
        $dom->strictErrorChecking = false;

        $dom->loadHTML($html);

        $hrefs = $dom->getElementsByTagName('a');

        echo "<pre>";
        print_r($hrefs);
        echo "</pre>";

        curl_close($ch);


    }else{
        echo "The website could not be reached.";
    }
Run Code Online (Sandbox Code Playgroud)

php html-parsing domdocument

12
推荐指数
2
解决办法
4万
查看次数

DOMDocument :: loadHTML():warning - htmlParseEntityRef:实体中没有名称

我发现了几个类似的问题,但到目前为止,没有人能够帮助我.

我试图在HTML块中输出所有图像的'src',所以我正在使用DOMDocument().这种方法非常有效,但我在某些页面上收到警告,我无法弄清楚原因.有些帖子建议压制警告,但我更愿意找出警告产生的原因.

警告:DOMDocument :: loadHTML():htmlParseEntityRef:实体中没有名称,行:10

其中一个例子post->post_content就是产生错误 -

On Wednesday 21st November specialist rights of way solicitor Jonathan Cheal of Dyne Drewett will be speaking at the Annual Briefing for Rural Practice Surveyors and Agricultural Valuers in Petersfield.
<br>
Jonathan is one of many speakers during the day and he is specifically addressing issues of public rights of way and village greens.
<br>
Other speakers include:-
<br>
<ul>
<li>James Atrrill, Chairman of the Agricultural Valuers Associates of …
Run Code Online (Sandbox Code Playgroud)

php warnings domdocument

12
推荐指数
2
解决办法
2万
查看次数