get_html_translation_table
(PHP 4, PHP 5)
get_html_translation_table — htmlspecialchars()와 htmlentities()에서 사용하는 변환표를 반환합니다.
설명
array get_html_translation_table
( int $table
[, int $quote_style
] )
get_html_translation_table()은 htmlspecialchars()와 htmlentities()에서 내부적으로 사용하는 변환표를 반환합니다.
원하는 테이블을 지정할 수 있게 하는 두가지 새로운 상수(HTML_ENTITIES, HTML_SPECIALCHARS)가 존재합니다. 그리고 htmlspecialchars()와 htmlentities() 함수와 마찬가지로, 사용할 quote_style 을 선택적으로 지정할 수 있습니다. 기본값은 ENT_COMPAT 모드입니다. 이 모드들에 대한 설명은 htmlspecialchars()를 참고하십시오.
Example#1 변환표 예제
<?php
$trans = get_html_translation_table(HTML_ENTITIES);
$str = "Hallo & <Frau> & Krämer";
$encoded = strtr($str, $trans);
?>
다른 사용법으로, array_flip()과 함께 이 함수를 사용하여 역변환을 할 수 있습니다.
<?php
$trans = array_flip($trans);
$original = strtr($encoded, $trans);
?>
참고: htmlspecialchars(), htmlentities(), strtr(), array_flip().