ID: 40155 Updated by: [EMAIL PROTECTED] Reported By: onerob at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: any PHP Version: Irrelevant New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2007-01-24 00:06:48] onerob at gmail dot com Correction and clarification: The PHP4 function example gets confused if you use a decimal HTML entity with a leading zero, e.g. ' instead of ' For example, the following code should really output a single quote character but actually outputs nothing - <?php // For users prior to PHP 4.3.0 you may do this: 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); } echo unhtmlentities('''); ?> To correct this, changing the following line from $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); to $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string); is adequate (double quotes added around \\1). A similar fix could no doubt be provided for the preceding line in the function, also. ------------------------------------------------------------------------ [2007-01-20 22:37:22] [EMAIL PROTECTED] can you please provide an example that exibits the bug in the function? ------------------------------------------------------------------------ [2007-01-17 15:35:32] onerob at gmail dot com Description: ------------ Single quotes need to be double quotes in the second line of the PHP 4 equivalent function example of html_entity_decode() that is provided by the documentation. http://uk2.php.net/manual/en/function.html-entity-decode.php#61610 Reproduce code: --------------- n/a Expected result: ---------------- n/a Actual result: -------------- n/a ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40155&edit=1