메뉴 건너뛰기

프로그램언어

조회 수 30410 추천 수 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. 리다이렉션(페이지 이동)의 3가지 방법, location.href

    Date2017.03.07 Views40135
    Read More
  2. [PHP] 게시판 글쓰기와 이미지 파일 DB 저장 및 불러오기 예제

    Date2017.02.19 Views35886
    Read More
  3. $_SERVER 환경변수

    Date2016.09.21 Views33237
    Read More
  4. PHP에서 PDF파일 생성하기

    Date2014.02.27 Views32777
    Read More
  5. PHP에서 자바스크립트 값 가져오기

    Date2014.02.27 Views31635
    Read More
  6. Class를 이용한 DB Connection 소스 (Oracle, MyS

    Date2014.02.27 Views30503
    Read More
  7. htmlentities <-> html_entity_decode (엔티티

    Date2014.04.12 Views30410
    Read More
  8. 무조건 알아야 할 PHP 속도 테스트 14 가지

    Date2014.02.27 Views30280
    Read More
  9. PHP로 Excel 파일 만들기...

    Date2014.02.27 Views30257
    Read More
  10. Text를 GD 이미지로 뿌리기

    Date2014.02.27 Views29813
    Read More
  11. php 엑셀 다운로드 구현

    Date2017.03.07 Views29786
    Read More
  12. 글내용 이미지 리사이징

    Date2014.02.27 Views29446
    Read More
  13. 쿠키변수받기

    Date2014.02.27 Views29211
    Read More
  14. Record Drag/Drop Position

    Date2014.02.27 Views29201
    Read More
  15. 간단한 PHP 파일 업로드, 다운로드 구현

    Date2017.03.06 Views28547
    Read More
  16. DB상의 많은 파일을 한꺼번에 다운받기

    Date2014.02.27 Views28332
    Read More
  17. GD를 이용한 스팸성 게시물 차단을 위한 보안 단어 입력 예제

    Date2014.02.27 Views26945
    Read More
  18. 주간날짜 뽑아오기

    Date2014.02.27 Views26731
    Read More
  19. 전화번호에 하이픈(-) 넣기

    Date2015.04.14 Views26622
    Read More
  20. PHP 변수전달 GET, POST

    Date2015.04.14 Views26566
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved