메뉴 건너뛰기

프로그램언어

조회 수 32370 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
htmlentities해당하는 모든 문자를 HTML 엔티티로 변환
 
string htmlentities ( string $string [, int $quote_style [, string $charset [, bool $double_encode ]]] )

htmlentities()는 HTML 문자 엔티티에 존재하는 모든 문자를 엔티티로 변환하는 점을 제외하면, htmlspecialchars()와 완전히 동일합니다.

디코드(역변환)하려면 html_entity_decode()를 사용할 수 있습니다.
 
Example #1 htmlentities() ------------------------------------------------------------------------------------
<?php
$str 
"A 'quote' is <b>bold</b>"
;

// 출력: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str
);

// 출력: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($strENT_QUOTES);
?>

--------------------------------------------------------------------------------------------------------------
 
html_entity_decode모든 HTML 엔티티를 해당하는 문자로 변환
 
string html_entity_decode ( string $string [, int $quote_style [, string $charset ]] )

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

 

Example #1 HTML 엔티티 디코딩---------------------------------------------------------------------------------
<?php
$orig 
"I'll \"walk\" the <b>dog</b> now"
;
$a htmlentities($orig
);
$b html_entity_decode($a
);
echo 
$a
// I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; 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
?>
----------------------------------------------------------------------------------------------------------------
 Note: trim(html_entity_decode('&nbsp;'));는 문자열을 빈 문자열로 변환하지 않습니다. 이는 기본값인 ISO-8859-1 문자셋에서 '&nbsp;' 엔티티가 (trim()에서 잘라내는) 아스키 코드 32

  1. fopen 파일 열기

    Date2015.04.14 Views21496
    Read More
  2. addslashes 함수의 필요성

    Date2015.04.14 Views25765
    Read More
  3. MySQL DB 중복여부 검사하여 없는 것만 추가

    Date2015.04.14 Views21288
    Read More
  4. 접속 IP 검사

    Date2015.04.14 Views22724
    Read More
  5. PHP 변수전달 GET, POST

    Date2015.04.14 Views27778
    Read More
  6. 문자열 치환하기

    Date2015.04.14 Views21596
    Read More
  7. 문자열 나누기

    Date2015.04.14 Views20847
    Read More
  8. PHP에서 조건문 처리

    Date2015.04.14 Views23131
    Read More
  9. 문자열 붙이기

    Date2015.04.14 Views20395
    Read More
  10. 홈페이지 귀퉁이에 붙이는 공지창

    Date2015.04.06 Views26457
    Read More
  11. [PHP] 서버 운영하시는분 서버 꺼졌을때 메시지 띄우기

    Date2015.04.06 Views21491
    Read More
  12. POST값 통째로 인코딩하기

    Date2015.04.06 Views22780
    Read More
  13. [PHP] POST 로 넘어온 모든 변수값 확인하기

    Date2015.03.25 Views24472
    Read More
  14. 한글줄바꾸기 또는 utf-8 wordwrap

    Date2014.04.11 Views27717
    Read More
  15. PHP 로그인후 현재 페이지로 돌아오기 처리

    Date2014.04.11 Views23738
    Read More
  16. php한글체크를 위한 정규표현식

    Date2014.04.11 Views23420
    Read More
  17. php 파일 다운로드 구현

    Date2014.04.11 Views22680
    Read More
  18. iframe 사용시 iframe의 높이가 내용의 높이만큼 자동으로 조절

    Date2014.04.11 Views22961
    Read More
  19. htmlentities <-> html_entity_decode (엔티티

    Date2014.04.11 Views32370
    Read More
  20. jquery 이용 아이디 중복체크 실시간

    Date2014.04.11 Views21341
    Read More
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved