PHPÖÐhtmlentitiesºÍhtmlspecialcharsº¯ÊýµÄÇø±ð
×öPHP³ÌÐòµÄÈ˶¼ÖªµÀhtmlentitiesºÍhtmlspecialcharsº¯Êý£¬¶¼ÊǸñʽ»¯html´úÂëµÄ£¬µ«ÊÇÕâ¶þ¸öº¯ÊýÊÇ·ñÕæµÄ¹¦ÄÜÒ»ÑùÂ𣿠php³ÌÐòÔ±Ö®¼Ò ÕâÁ½¸öº¯ÊýÔÚ¸ñʽ»¯´øÓÐÓ¢ÎÄ×Ö·ûµÄhtml´úÂëµÄʱºò»ù±¾Ã»É¶ÎÊÌ⣬µ«ÊÇhtmlentities¶ÔÖÐÎÄ×Ö·ûÒ²²»·Å¹ý£¬ÕâÑùµÃ³öÀ´µÄ½á¹ûÊÇÖÐÎÄ×Ö·û²¿·Ö±äΪһ¶ÑÂÒÂë¡£µ±Ê±×öÓ¢ÎÄÕ¾µÄʱºò¸ù±¾¾Íû¾õ²ìµ½Õâ¸öÎÊÌ⣬¶ø½ñÌ칫˾µÄÒ»¸öÊÕ²ØվȴÒòΪÓÐÓзÇÓ¢ÎÄ×Ö·û¶ø³öÏÖÁËÎÊÌ⣬ÎÒ×îÖÕ²é³öÀ´ÊÇ htmlentitiesÕâ¸öº¯ÊýµÄÎÊÌ⣬ͬʱÎÒÒ²ÕÒµ½ÁËhtmlspecialcharsÕâ¸öº¯Êý¡£
¶ÔÓÚÕâÁ½¸öº¯Êý£¬phpÊÖ²áÉ϶¼ÊÇÓ¢ÎÄ×öµÄ½âÊÍ£¬ÆäÖÐÔÚhtmlentitiesº¯ÊýµÄ˵Ã÷²¿·ÖÓÐÕâôһ¶ÎÓ¢ÎÄ£º
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
´ÓÕâ¾ä»°ÖÐÎÒÃÇÒ²¿ÉÒÔ¿´³öÀ´ÕâÁ½¸öº¯ÊýËäÈ»»ù±¾¹¦Äܲ¶à£¬µ«ÊÇ»¹ÊÇÓÐϸ΢µÄ²î±ðÔÚÀïÃæµÄ¡£ÔÙ×Ðϸ¿´htmlspecialcharsº¯ÊýÀïÃæµÄÒ»¶Î»°£º
The translations performed are:
¡®&' (ampersand) becomes ¡®&'
¡®¡±¡® (double quote) becomes ¡®¡±¡® when ENT_NOQUOTES is not set.
¡±' (single quote) becomes ¡±' only when ENT_QUOTES is set. www.phperz.com
¡®<' (less than) becomes ¡®<'
¡®>' (greater than) becomes ¡®>' php³ÌÐòÔ±Õ¾ ¿ÉÒÔÁ˽⵽htmlspecialcharsֻת»¯ÉÏÃæÕ⼸¸öhtml´úÂ룬¶øhtmlentitiesÈ´»áת»¯ËùÓеÄhtml´úÂ룬Á¬Í¬ÀïÃæµÄËüÎÞ·¨Ê¶±ðµÄÖÐÎÄ×Ö·ûÒ²¸øת»¯ÁË¡£
ÎÒÃÇ¿ÉÒÔÄÃÒ»¸ö¼òµ¥µÄÀý×ÓÀ´×ö±È½Ï£º www~phperz~com ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
$str='<a href="test.html">²âÊÔÒ³Ãæ</a>';
echo htmlentities($str); $str='<a href="test.html">²âÊÔÒ³Ãæ</a>';
echo htmlspecialchars($str); ÓÐÌõ¼þµÄÅóÓÑ£¬¿ÉÒÔ·Ö±ðÔËÐÐÒ»ÏÂÉÏÃæµÄÕâÁ½¶Î´úÂ룬¾Í¿ÉÒÔ¿´³öÁ½ÕߵIJî±ðÁË¡£ ___________________________________________________________________________________ htmlspecialchars°ÑijЩÌØÊâ×Ö·ûת»»³ÉhtmlµÄ±àÂ룬³£Óõ½µÄ³¡ºÏ¿ÉÄܾÍÊÇ´¦Àí¿Í»§ÁôÑÔµÄÁôÑÔ°æÁË¡£ ÕâЩÌØÊâ×Ö·û½öÏÞÓÚÒÔϼ¸¸ö£º & -> &
Ïà¹ØÎĵµ£º
·þÎñÆ÷±äÁ¿ $_SERVER Ïê½â£º
1¡¢$_SESSION['PHP_SELF'] -- »ñÈ¡µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû
2¡¢$_SERVER['SERVER_PROTOCOL'] -- ÇëÇóÒ³ÃæʱͨÐÅÐÒéµÄÃû³ÆºÍ°æ±¾¡£ÀýÈ磬“HTTP/1.0”¡£
3¡¢$_SERVER['REQUEST_TIME'] -- ÇëÇó¿ªÊ¼Ê±µÄʱ¼ä´Á¡£´Ó PHP 5.1.0 ÆðÓÐЧ¡£ºÍtimeº¯ÊýЧ¹ûÒ»Ñù¡£
4¡¢$_SERVER['a ......
cookieĬÈϲ»ÄÜ´æÊý×飬ËùÒÔÏÂÃæµÄд·¨ÊÇ´íÎóµÄ¡£
<?php
$arr = array(1,2,3);
setcookie('a',$arr);
$arr = array(1,2,3);
setcookie('a',$arr);
?>
±¨´íÈçÏ£º
Warning: setcookie() expects parameter 2 to be string, array given in
µ«ÊÇPHP¿ÉÒÔ°ÑͬÃûÇÒºóÃæÒÔ[]½áβµÄcookie½âÎöΪÊý×é¡£ÔÚ ......
ÔÚPHP½øÐÐÐòÁл¯Ê±£¬serialize() ¼ì²éÀàÖÐÊÇ·ñÓÐ __sleep() ,Èç¹ûÓУ¬Ôò¸Ãº¯Êý½«ÔÚÈκÎÐòÁл¯Ö®Ç°ÔËÐС£¸Ãº¯Êý±ØÐë·µ»ØÒ»¸öÐèÒª½øÐÐÐòÁл¯±£´æµÄ³ÉÔ±ÊôÐÔÊý×飬²¢ÇÒÖ»ÐòÁл¯¸Ãº¯Êý·µ»ØµÄÕâЩ³ÉÔ±ÊôÐÔ. ¸Ãº¯ÊýÓÐÁ½¸ö×÷ÓÃ: µÚÒ». ÔÚÐòÁл¯Ö®Ç°,¹Ø±Õ¶ÔÏó¿ÉÄܾßÓеÄÈκÎÊý¾Ý¿âÁ¬½ÓµÈ. µÚ¶þ. Ö¸¶¨¶ÔÏóÖÐÐèÒª±»ÐòÁл¯µÄ³ÉÔ±ÊôÐÔ,È ......
strtotimeº¯ÊýÊÇÒ»¸öºÜºÃµÄº¯Êý,Áé»îµÄÔËÓÃËü,»á¸øÄãµÄ¹¤×÷´øÀ´²»ÉÙ·½±ã.µ«PHPµÄÊÖ²áÖÐÈ´¶Ô´Ëº¯ÊýµÄ²ÎÊýû×÷Ì«¶à½éÉÜ,¶ÔЩº¯ÊýµÄÆäËû½éÉÜÒ²·Ç³£ÉÙ¡£
ÏÈ¿´ÊÖ²á½éÉÜ£º
strtotime — ½«ÈκÎÓ¢ÎÄÎı¾µÄÈÕÆÚʱ¼äÃèÊö½âÎöΪ Unix ʱ¼ä´Á
¸ñʽ£ºint strtotime ( string $time [, int $now ] )
¡¡¡¡±¾º¯ÊýÔ¤ÆÚ½ÓÊÜÒ ......