html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환

html_entity_decode — 모든 HTML 엔티티를 해당하는 문자로 변환 

 

string html_entity_decode ( string $string [, int $quote_style [, string $charset ]] )

html_entity_decode()는 string의 모든 HTML 엔티티를 해당하는 문자로 변환합니다. htmlentities()의 역함수입니다.

 

<?php

$orig = "I'll \"walk\" the <b>dog</b> now";

 

$a = htmlentities($orig);

 

$b = html_entity_decode($a);

 

echo $a; // I'll "walk" the <b>dog</b> now

 

echo $b; // I'll "walk" the <b>dog</b> now

 

 

// PHP 4.3.0 이전 사용자는 이렇게 할 수 있습니다:

function unhtmlentities($string)

{

    // 숫자 엔티티 치환

    $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);

    // 문자 엔티티 치환

    $trans_tbl = get_html_translation_table(HTML_ENTITIES);

    $trans_tbl = array_flip($trans_tbl);

    return strtr($string, $trans_tbl);

}

 

$c = unhtmlentities($a);

 

echo $c; // I'll "walk" the <b>dog</b> now

 

?>

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
기타 9년 전 조회 2,413
기타 9년 전 조회 3,821
PHP 9년 전 조회 2,354
웹서버 9년 전 조회 5,292
PHP 9년 전 조회 2,446
기타 9년 전 조회 3,297
PHP 9년 전 조회 2,786
PHP 9년 전 조회 2,426
PHP 9년 전 조회 2,917
기타 9년 전 조회 2,995
jQuery 9년 전 조회 2,568
기타 9년 전 조회 3,317
MySQL 9년 전 조회 3,860
PHP 9년 전 조회 3,006
PHP 9년 전 조회 2,331
PHP 9년 전 조회 2,430
PHP 9년 전 조회 3,013
PHP 9년 전 조회 2,614
PHP 9년 전 조회 3,679
PHP 9년 전 조회 3,181
PHP 9년 전 조회 6,058
PHP 9년 전 조회 5,794
PHP 9년 전 조회 3,125
PHP 9년 전 조회 3,748
PHP 9년 전 조회 3,560
PHP 9년 전 조회 5,640
PHP 9년 전 조회 3,134
PHP 9년 전 조회 4,580
PHP 9년 전 조회 3,537
PHP 9년 전 조회 3,656