get_html_translation_table
(PHP 4, PHP 5)
get_html_translation_table — Geeft een vertalingstabel weer die gebruikt wordt bij htmlspecialchars() en htmlentities()
Beschrijving
get_html_translation_table() geeft een vertalingstabel weer die intern gebruikt wordt voor htmlspecialchars() en htmlentities(). Er zijn twee nieuwe defines (HTML_ENTITIES , HTML_SPECIALCHARS ) die het mogelijk maken om te specifieren welke tabel je wilt. En net als bij de htmlspecialchars() en htmlentities() functies kan je optioneel de quote_style specifieren die je gebruiken wilt. De default is ENT_COMPAT mode. Zie de omschrijving van deze modes in htmlspecialchars().
Example#1 Vertalingstabel Voorbeeld
$trans = get_html_translation_table (HTML_ENTITIES);
$str = "Hallo & <Frau> & Krämer";
$encoded = strtr ($str, $trans);
Leuk is het gebruikmaken van array_flip() om de richting van de vertaling te veranderen.
$trans = array_flip ($trans);
$original = strtr ($str, $trans);
Zie ook: htmlspecialchars(), htmlentities(), strtr(), en array_flip().