php ºº×Öת»¯³É ¶þ½øÖÆ Ê®½øÖÆ Ê®Áù½øÖÆ Êý×Ö
<?php
/**
* °ÑÒ»¸öºº×ÖתΪunicodeµÄͨÓú¯Êý£¬²»ÒÀÀµÈκο⣬ºÍ±ðµÄ×Ô¶¨Ò庯Êý£¬µ«ÓÐÌõ¼þ
* Ìõ¼þ£º±¾ÎļþÒÔ¼°º¯ÊýµÄÊäÈë²ÎÊýÓ¦¸ÃÓÃutf-8±àÂ룬²»È»Òª¼Óº¯Êýת»»
* ÆäʵÒà¿ÉÇáÒ×±àд·´Ïòת»»µÄº¯Êý£¬ÉõÖÁ²»¾ÖÏÞÓÚºº×Ö£¬Ææ¹ÖΪʲôPHPûÓÐÏֳɺ¯Êý
* @author xieye
*
* @param {string} $word ±ØÐëÊÇÒ»¸öºº×Ö£¬»ò´ú±íºº×ÖµÄÒ»¸öÊý×é(ÓÃstr_splitÇиî¹ý)
* @return {string} Ò»¸öÊ®½øÖÆunicodeÂ룬Èç4f60£¬´ú±íºº×Ö “Äã”
*
* @example
echo "Äã ".getUnicodefromOneUTF8("Äã");
echo "<br />";
echo "ºÃ ".getUnicodefromOneUTF8("ºÃ");
echo "<br />";
echo "ÄãºÃ ".getUnicodefromOneUTF8("ÄãºÃ");
echo "<br />";
echo "ÄãºÃÂð ".getUnicodefromOneUTF8("ÄãºÃÂð");
Äã 20320
ºÃ 22909
ÄãºÃ 251503099357000
ÄãºÃÂð 4.21952182258E+21
*/
function getUnicodefromOneUTF8($word) {
//»ñÈ¡Æä×Ö·ûµÄÄÚ²¿Êý×é±íʾ£¬ËùÒÔ±¾ÎļþÓ¦ÓÃutf-8±àÂë!
if (is_array( $word))
$arr = $word;
else
$arr = str_split($word);
//´Ëʱ£¬$arrÓ¦ÀàËÆarray(228, 189, 160)
//¶¨ÒåÒ»¸ö¿Õ×Ö·û´®´æ´¢
$bin_str = '';
//ת³ÉÊý×ÖÔÙת³É¶þ½øÖÆ×Ö·û´®£¬×îºóÁªºÏÆðÀ´¡£
foreach ($arr as $value)
$bin_str .= decbin(ord($value));
//´Ëʱ£¬$bin_strÓ¦ÀàËÆ111001001011110110100000,Èç¹ûÊǺº×Ö"Äã"
//ÕýÔò½ØÈ¡
$bin_str = preg_replace('/^.{4}(.{4}).{2}(.{6}).{2}(.{6})$/','$1$2$3', $bin_str);
//´Ëʱ£¬ $bin_strÓ¦ÀàËÆ0100111101100000,Èç¹ûÊǺº×Ö"Äã"
return bindec($bin_str);
//·µ»ØÀàËÆ20320£¬ ºº×Ö"Äã"
//return dechex(bindec($bin_str));
//ÈçÏë·µ»ØÊ®Áù½øÖÆ4f60£¬ÓÃÕâ¾ä
}
echo "Äã ".getUnicodefromOneUTF8("Äã");
echo "<br />";
echo "ºÃ ".getUnicodefromOneUTF8("ºÃ");
echo "<br />";
echo "ÄãºÃ ".getUnicodefromOneUTF8("ÄãºÃ");
echo "<br />";
echo "ÄãºÃÂð ".getUnicodefromOneUTF8("ÄãºÃÂð");
exit;
?>
Ïà¹ØÎĵµ£º
PHPÊÇÒ»¸öºÜÓÅÐãµÄ¹¤¾ß£¬Ëü¿ÉÒÔ¼òµ¥£¬Ò²¿ÉÒÔ¸´ÔÓ¡£²»Ò»ÑùµÄÏîÄ¿£¬Ó¦¸ÃÓò»Ò»ÑùµÄPHP¡£
СÏîÄ¿ - ¼òµ¥¶øÖ±½ÓµÄPHP
Ò»°ã¶ÔÓÚÒ»¸ö¹¦ÄÜÒ³ÃæÔÚ20ÒÔϵÄÍøÕ¾£¬ÎÒÃÇ¿ÉÒÔÓÃÒ»¸öºÜ¼òµ¥µÄ¿ò¼Ü½á¹¹À´Ð´¡£ÔÚÕâ¸ö¹æÄ£ÉÏ£¬ÎÒ½¨ÒéÊÇʹÓñȽÏÖ±½ÓµÄÃæÏò¹ý³Ì±àÂë·½·¨£¬ÔÒòºÜ¼òµ¥£¬Ã»ÓбØÒª°ÑclassÎļþŪµÄN ¶à£¬½ ......
<?php
header("content-type:image/png");
$img=ImageCreate(100,35);
$bgcolor=ImageColorAllocate($img,0,0,0);
$red=ImageColorAllocate($img,255,0,0);
$bgcolortrans=ImageColorTransparent($img,$bgcolor);
ImageString($img,5,10,10,"PNG PHP",$red);
ImagePng($img);
ImageDestro ......
½üÈÕÒò¹«Ë¾¿ª·¢ÐèÒª,ÔÚ±¾»úWin7ϼÜÉèÁËApache+MySql+PHP
ËùʹÓÃPHP°æ±¾:PHP5.3.0, Ö®ºó·¢ÏÖÎÞ·¨Á¬½ÓmysqlÊý¾Ý¿â,¾ù±¨³¬Ê±´íÎó:
PHP Warning: mysqli::mysqli(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in xxx.php on line x
PHP Warni ......
×÷Ϊһ¸öphp³ÌÐòÔ±À´Ëµ¡£¡£ÓÐʲôÊÇÎÒÃÇÓ¦¸ÃÖªµÀµÄÄØ£¿
Ê×ÏÈÀ´ËµÒ»Ï¡£phpÖ®ËùÒÔÄܹ»ÔÚ¹úÄÚ×ߺ졣¡£Æä×îÖØÒªµÄÒ»µã¾ÍÊÇËûÊÇ¿ªÔ´µÄ¡£ºÃ¶àÓÅÐãµÄ¶«Î÷¶¼¿ÉÒÔÃâ·ÑµÄÄÃÀ´Óá£ÏÖÔÚÊÐÃæÉÏÓÐÄÇô¶¼µÄphp¿ªÔ´²úÆ·¡£µ±ÎÒÃÇÐèÒª×öÒ»¸öÏà¹ØµÄÍøÕ¾µÄʱºò¡£Ö»Òª°ÑÈ˼ҵIJúÆ·ÄùýÀ´¡£¸ù¾Ý×Ô¼ºµÄÐèÒª×ö¶þ´Î¿ª·¢¾Í¿ÉÒÔÁË¡£¡£´Ó¶øʹphpÏîÄ¿µÄ ......
ÃæÏò¶ÔÏó±à³ÌµÄ·½·¨ÖУ¬ÎªÁËʵÏÖ¶ÔÏó¼äµÄËÉñîºÏ£¬ÆäÖÐÒ»ÖÖ¼òµ¥µÄÔÔò¾ÍÊǽ«Ó¦ÓòßÂÔÓ빦ÄÜʵÏÖ·ÖÀë¡£³£³£Óõ½µÄÉè¼ÆģʽÓÐfactory¡¢facadeµÈ£¬¶øµ±ÖеĺËÐıà³Ì¼¼Êõ¾ÍÊÇcallback¼¼Êõ¡£
Ëùνcallback¼¼Êõ£¬¼òµ¥µÄ˵¾ÍÊǽ«º¯ÊýµÄ×÷Ϊһ¸ö²ÎÊý´«µÝ¸øÁíÍâÒ»¸öº¯Êý£¬²¢±»¸Ãº¯ÊýËùµ÷Óá£
phpÏ£¬ÊµÏÖ¹¤³§Ä£Ê½µÄÓÐһϡ£¼¸¸ö¹Ø¼ü ......