ÓÃPHPÈçºÎÅжÏÒ»¸öÎļþµÄ±àÂ룿
ÕûÀí×Ô£ºhttp://bbs.phpchina.com/viewthread.php?tid=18006
Îļþa.txt£¬ÓÃPHPÈçºÎÅжÏËüµÄ±àÂëÊÇGBK»¹ÊÇUTF-8ÄØ£¿
1£¬ÖØÐÂÈÏʶһÏ´ËÎÊÌ⣬µ±Ê±°æÖ÷»Ø¸´µÄʱºòÎҾ;õµÃmbº¯ÊýÀïÒ»¶¨ÓÐÕâÑùµÄ¹¦ÄÜ£¬µ«½ñÈÕÑо¿ÁËmb¿â£¬²¢Ã»ÓÐÕâÑùµÄ¹¦ÄÜ¡£ÓÃmb_detect_encoding×ÜÊDz»×¼È·¡£
echo mb_detect_encoding(file_get_contents('a.txt'));
2£¬ÎÒÔÚPHPµÄÔÚÏßÎĵµÖÐÕÒÁËÒ»¸ö·½·¨£¬¿ÉÒÔ½â¾öÄãµÄÎÊÌ⣬ÐèÒª×Ô¼º±àдһ¸öº¯ÊýÀ´ÊµÏÖ¡£
¾ßÌå´úÂëÈçÏ£º
function isUTF8($str)
{
if ($str === mb_convert_encoding(mb_convert_encoding($str, "UTF-32", "UTF-8"), "UTF-8", "UTF-32"))
{
return true;
}
else
{
return false;
}
}
$content = file_get_contents("a.txt");
echo isUTF8($content);
3£¬¾²âÊÔ£¬ÔÚ±àÂëÖÖÀ಻¶àµÄÇé¿öÏ£¬2·½·¨³É¹¦ÂÊ»¹ÊÇͦ¸ßµÄ¡£
function ChickC($str)
{
$array = array('ASCII','GBK','UTF-8');
foreach ($array as $value)
{
if ($str === mb_convert_encoding(mb_convert_encoding($str, "UTF-32", $value), $value, "UTF-32"))
return $value;
}
return false;
}
Ïà¹ØÎĵµ£º
¡¡¡¡ËäÈ»PHPÊÇWebÓ¦Óÿª·¢ÖÐ×î¹ã·ºÊ¹ÓõĻ·¾³£¬µ«Ëü»¹ÊÇÒ»¶È±»ÈÏΪÎÞÔµÆóÒµ¼¶¿ª·¢¡£InfoQ×éÖ¯ÁËÒ»¸öÐéÄâ×ù̸С×éÀ´ÌÖÂÛÓïÑÔ/ƽ̨µÄÑݱ估PHPÔÚÆóÒµ»·¾³ÏµÄÊÊÓÃÐÔ¡£
¡¡¡¡Zeev Suraski£¬Zend Technologies¹«Ë¾´´Ê¼ÈË£¬¸Ã¹«Ë¾Ö÷Òª¹Ø×¢PHPµÄ½øÕ¹¡£
¡¡¡¡Rob Nicholson£¬¸ß¼¶¼¼ÊõÑÐÔ±, ÔøΪIBM±àд¹ý³ÌÐòÉè¼ÆÓïÑÔÔËÐÐʱ¡£
¡¡¡ ......
ÎÊÌâÃèÊö£ºÒ»¸öÁ¬½ÓÔ¶³ÌÊý¾Ý¿âµÄPHP½Å±¾testdb.php£¬ÔÚä¯ÀÀÆ÷ÖÐÔËÐУºhttp://localhost/testdb.php£¬³öÏÖ´íÎó£ºCan't connect to MySQL server on '10.60.56.220' (13)£¬µ«ÊÇÔÚ±¾µØÓÃphpÃüÁîÐÐÔËÐУºphp testdb.php£¬È´Õý³£µØÁ¬ÉÏÁËÊý¾Ý¿â²¢¶Á³öÁËÆäÖеÄÊý¾Ý¡£
Ó¦ÓóÌÐò»·¾³£º±¾µØIP£º10.60.56.90£¬±¾µØµçÄÔÉÏ°²×°Apache 2 ......
<?php
class DB
{
private $link;
function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)
{
if($pconnect)
{
if(!$this->link = mysql_pconnect($dbhost, $dbuser, ......
1.ÓÃJSµ÷ÓÃÎļþcount.php ÔÚÄãÐèÒª¼ÓÈëͳ¼ÆµÄµÄµØ·½¼ÓÈë<script src="count.php"></script> ʵ¼ÊÔËÓÃÖÐ×¢ÒâÐ޸ķ¾¶£¡
2.php»·¾³±ØÐëÖ§³Öputenv()º¯Êý,¿ÉÒÔͳ¼Æ×òÈÕ·ÃÎÊ£¬½ñÈÕ·ÃÎÊ£¬ÔÚÏßÈËÊý,Äú·ÃÎʵĴÎÊý¡£
3 . ......
½üÈÕÔÚÓÃ×Ô¼ºÒÔǰдµÄhttpÏÂÔØÆ÷ÏÂÔØijһ¸öphpÒ³ÃæÒÔÍâÔâÓö403´íÎó.µ«ÊÇieÈ´Äܹ»ÕýÈ··ÃÎÊ. ÈÕÖ¾ÈçÏÂ: IE: Time At:0005504671
Line:10
send: 192.168.1.2 –> xxx.xxx.xxx.xxx len:351
GET /test.jpg HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Enc ......