0

in arabic page after using this function

function getNodeOuterHTML($n) {
    $d = new DOMDocument('1.0');
    $b = $d->importNode($n->cloneNode(true),true);
    $d->appendChild($b);
    $h = $d->saveHTML();
    return utf8_decode($h);
}

it gives "رام الله" its arabic work calls "رام الله"

How can i convert it to that arabic text, it appear in the browser arabic but not in the source

4

1 回答 1

6

您可以使用html_entity_decode; 它还将解码像这样的数字实体引用。

echo html_entity_decode("رام الله");

输出:رام الله

如果您使用的是旧版本的 PHP,则必须传递编码参数。在 5.4 之前,假定使用 ISO-8859-1 编码。

echo html_entity_decode($str, ENT_COMPAT|ENT_HTML401, 'UTF-8');
于 2013-09-05T18:32:25.103 回答