PHP 8.5.0 Alpha 4 available for testing

Voting

: max(five, four)?
(Example: nine)

The Note You're Voting On

zachatwork at gmail dot com
16 years ago
You can easily avoid the warning about   references by using the LIBXML_DTDLOAD option.

<?php

$html
= <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<p>&nbsp;</p>
</body>
</html>
EOF;

// This one works perfectly.
$dom = new DOMDocument();
$dom->loadXML($html, LIBXML_DTDLOAD);
print
$dom->saveXML();

// This one produces a warning.
$dom = new DOMDocument();
$dom->loadXML($html);
print
$dom->saveXML();

?>

See also: http://www.php.net/manual/en/libxml.constants.php

Note that libxml will detect that your DTD is locally available via /etc/xml/catalog. So there is no worry about this causing your DOM loads to make external network requests.

<< Back to user notes page

To Top