- var_dump: documentation ( source)
<?php
$var = '<!DOCTYPE sgml [
<!ELEMENT sgml ANY>
<!ENTITY % std "standard SGML">
<!ENTITY % signature " — &author;.">
<!ENTITY % question "Why couldn’t I publish my books directly in %std;?">
<!ENTITY % author "William Shakespeare">
]>
<sgml>&question;&signature;</sgml>';
$dom = new DOMDocument;
$dom->loadXML($var);
var_dump($dom->doctype->entities->length);