php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33553 get_html_translation_table() ambiguous
Submitted: 2005-07-03 17:09 UTC Modified: 2005-07-08 10:58 UTC
From: goba@php.net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
 [2005-07-03 17:09 UTC] goba@php.net
Description:
------------
get_html_translation_table() returns an array with two keys having value "'" (the ampersand). When array_flip()-ed, as suggested by the manual, the second one overwrites the first, thus giving a reverse table with only one ampersand key. Using this reverse table to convert back a string is not possible, since the original table had the other representation of the ampersand first, and used that for translation.

See http://lxr.php.net/source/php-src/ext/standard/html.c#466

Note that if this is not deemed to be a PHP bug, then this irreversibility issue should be documented.

Reproduce code:
---------------
var_dump(htmlspecialchars("'", ENT_QUOTES));
var_dump(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES));
var_dump(array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)));


Expected result:
----------------
No ambigous array elements in the translation table.

Actual result:
--------------
Two entries for the ampersand.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-03 17:15 UTC] derick@php.net
You surely mean slash here, and not ampersand? Anyway, this is not a PHP bug but a documentation issue.
 [2005-07-03 17:24 UTC] goba@php.net
Sorry, I mean single quote, as it is evidenced by the lxr link I provided.
 [2005-07-08 10:58 UTC] vrana@php.net
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.

"Special characters can be encoded in several ways. E.g. " can be encoded as ", " or &#x22. get_html_translation_table() returns only the most common form for them."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 08:01:34 2025 UTC