(PHP 5, PHP 7)

DOMDocument::createEntityReferenceCrée un nouveau noeud de référence d'entité


public DOMEntityReference DOMDocument::createEntityReference ( string $name )

Cette fonction crée une nouvelle instance de la classe DOMEntityReference. Ce noeud ne sera pas affiché dans le document, à moins qu'il ne soit inséré avec DOMNode::appendChild().

Liste de paramètres


Le contenu de la référence de l'entité, e.g. la référence de l'entité sans le & initial et le ; final.

Valeurs de retour

Le nouveau DOMEntityReference ou FALSE si une erreur survient.

Erreurs / Exceptions


Emise si name contient un caractère invalide.

Voir aussi

add a note add a note

User Contributed Notes 2 notes

alicewonder at shastaherps dot org
2 months ago
It appears that this does not work with numbered entities, only named entities.

$nbspace = $dom->createEntityReference('nbsp');


$nbspace = $dom->createEntityReference('#160');

does not. This makes this function rather useless when generating an XSL unless you modify the XSL doctype to include the named entity for the character you want.
Tuhin Bepari
2 years ago
/*Entity is a group of words which print a special symbol.
Like if we want to show copy right symbol in html page then we use &copy; code and browser convert this to actual copyright symbol.
There have lots of entity, you can find them all form
if you want to use < or > or both <> into a node value than xml will give and warning or make this value as a node.
So tell the xml parser that < or > is not tag symbol it is a entity.To do that you have to right &lt(<) and &gt;(>) instead of < and > symbol.

Entity references always begin with an ampersand (&) and end with a semicolon (;).
DO not need to use & and ; symbol begin and end of entity.Remove it when you want to use it to DOMDocument::createEntityReference
Then append to to a tag where you want to show this symbol.Like below
$dom=new DOMDocument("1.0","UTF-8");
$example=$dom->createElement("example","This is copyright ");

output is
This is copyright ©
To Top