This code below gives me a DOMDocument Warning and I wonder why. Is there anything I can do to fix it, or not display this particular warning? I'm running php on windows xp and iis.
$content = "<html><body><p>'HTTP_REFERER' => 'http://localhost/?table=event_occurrence_person&LB1ID='</p></body></html>";
$dom = new DOMDocument;
$dom->loadHTML($content);
Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1 in...
There's a bare &
in the HTML. &
signals the start of an HTML entity, a bare &
needs to be represented as the entity &
. That's where the warning comes from.
You can silence warnings using @
:
@$dom->loadHTML($content);
If you have full control over the HTML, you should not silence warnings. If you are parsing other people's HTML, you may have no choice.
Well, your XML is malformed.
=>
must be escaped to =>
(optional, not blocking) &LB1ID
must be escaped to &LB1ID
(raises your warning)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.