無料スクリプト配布のPHP.TO   PHPの実用的なtips PHPマニュアル MySQLマニュアル Apacheマニュアル PostgreSQLマニュアル マニュアル検索    

htmlentities

(PHP 4, PHP 5)

htmlentities??? HTML ???

string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )

?htmlspecialchars()?? HTML ??????HTML????

?? (?) ?? html_entity_decode() ?????

??

string

?

flags

?????????? ???????? ??? ENT_COMPAT | ENT_HTML401 ?

?? flags
?
ENT_COMPAT ??????????
ENT_QUOTES ??????????
ENT_NOQUOTES ??????????
ENT_IGNORE ???????? ???????????? ??????? » ?????
ENT_SUBSTITUTE ???????? ????? Unicode ???? UTF-8 U+FFFD? &#FFFD; ???
ENT_DISALLOWED ??????Unicode ?? U+FFFD (UTF-8) ? &#FFFD; ?? ???????? ??? XML ?????
ENT_HTML401 ? HTML 4.01 ???
ENT_XML1 ? XML 1 ???
ENT_XHTML ? XHTML ???
ENT_HTML5 ? HTML 5 ???

encoding

??????????

encoding ????varies PHP ????? PHP 5.6.0 ???????? default_charset ???PHP 5.4 PHP 5.5 ???? UTF-8 ? PHP ??? ISO-8859-1 ?

????PHP 5.5 ??? default_charset ??????????? ????????

???????

???
? ?
ISO-8859-1 ISO8859-1 Latin-1
ISO-8859-5 ISO8859-5 ?????? (Latin/Cyrillic)
ISO-8859-15 ISO8859-15 Latin-9 Latin-1(ISO-8859-1) ?? ??????
UTF-8   ASCII ?? 8 ? Unicode
cp866 ibm866, 866 DOS ???
cp1251 Windows-1251, win-1251, 1251 Windows ???
cp1252 Windows-1252, 1252 Windows ???
KOI8-R koi8-ru, koi8r ?
BIG5 950 ?????
GB2312 936 ?????
BIG5-HKSCS   Big5 ????
Shift_JIS SJIS, SJIS-win, cp932, 932 ??
EUC-JP EUCJP, eucJP-win ??
MacRoman   Mac OS ????
''   ??? ???? (Zend multibyte) default_charset ?? (nl_langinfo() setlocale() ??) ?????? ????

: ????? ???????????

double_encode

double_encode ????PHP ? html ?????? ?????????????

?

?????

??? encoding ?????? ENT_IGNORE ? ENT_SUBSTITUTE ?????????

?

5.6.0 encoding ????? default_charset ???
5.4.0 encoding ????? UTF-8 ??
5.4.0 ENT_SUBSTITUTEENT_DISALLOWED ENT_HTML401ENT_XML1 ENT_XHTML ENT_HTML5 ??
5.3.0 ENT_IGNORE ??
5.2.3 double_encode ????

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);
?>

2 ENT_IGNORE

<?php
$str 
"\x8F!!!";

// : ?
echo htmlentities($strENT_QUOTES"UTF-8");

// : "!!!"
echo htmlentities($strENT_QUOTES ENT_IGNORE"UTF-8");
?>



powered by SEO.CUG.NET