note 101347 added to function.html-entity-decode

From: Date: Sat, 11 Dec 2010 19:26:07 +0000
Subject: note 101347 added to function.html-entity-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-174801@lists.php.net to get a copy of this message
I think we should make a small change to function unhtmlentities in this manual page to avoid the "Bug #25927 get_html_translation_table calls the ' ' instead of '" function unhtmlentities($string) { // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string); // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl); } become function unhtmlentities($string) { // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#0*([1-9]+);~e', 'chr("\\1")', $string); // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl); } we replace '~&#([0-9]+);~e' with '~&#0*([1-9]+);~e' to make sure chr consider the number as decimal rather than octal. ---- Server IP: 69.147.83.197 Probable Submitter: 212.107.119.82 ---- Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php Edit -- https://master.php.net/note/edit/101347 Del: integrated -- https://master.php.net/note/delete/101347/integrated Del: useless -- https://master.php.net/note/delete/101347/useless Del: bad code -- https://master.php.net/note/delete/101347/bad+code Del: spam -- https://master.php.net/note/delete/101347/spam Del: non-english -- https://master.php.net/note/delete/101347/non-english Del: in docs -- https://master.php.net/note/delete/101347/in+docs Del: other reasons-- https://master.php.net/note/delete/101347 Reject -- https://master.php.net/note/reject/101347 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174801) next »