[ÕªÒª]±¾ÆªÎÄÕ¾͸ø´ó¼Ò¾ÙÀý½éÉÜphpÖÐÓÐÄÄЩ³£ÓÃ×Ö·û´®¡£ÓÐÒ»¶¨µÄ²Î¿¼¼ÛÖµ£¬ÓÐÐèÒªµÄÅóÓÑ¿ÉÒԲο¼Ò»Ï£¬Ï£Íû¶ÔÄãÃÇÓÐËù°ïÖú¡£//Êä³öÒ»¸ö»ò¶à¸ö×Ö·û´®
//×¢£ºecho ²»ÊÇÒ»¸öº¯Êý£¨ËüÊÇÒ»¸öÓïÑԽṹ£©£¬ Òò...
±¾ÆªÎÄÕ¾͸ø´ó¼Ò¾ÙÀý½éÉÜphpÖÐÓÐÄÄЩ³£ÓÃ×Ö·û´®¡£ÓÐÒ»¶¨µÄ²Î¿¼¼ÛÖµ£¬ÓÐÐèÒªµÄÅóÓÑ¿ÉÒԲο¼Ò»Ï£¬Ï£Íû¶ÔÄãÃÇÓÐËù°ïÖú¡£
//Êä³öÒ»¸ö»ò¶à¸ö×Ö·û´®
//×¢£ºecho ²»ÊÇÒ»¸öº¯Êý£¨ËüÊÇÒ»¸öÓïÑԽṹ£©£¬ Òò´ËÄã²»Ò»¶¨ÒªÊ¹ÓÃСÀ¨ºÅÀ´Ö¸Ã÷²ÎÊý£¬µ¥ÒýºÅ£¬Ë«ÒýºÅ¶¼¿ÉÒÔ$a = "admin1";$b = "adminb";echo $a, $b . "<br/>";//ʹÓÃÒ»¸ö×Ö·û´®·Ö¸îÁíÒ»¸ö×Ö·û´®
//array explode ( string $delimiter , string $string [, int $limit ] )
//×¢£ºÈç¹ûÉèÖÃÁË limit ²ÎÊý²¢ÇÒÊÇÕýÊý£¬Ôò·µ»ØµÄÊý×é°üº¬×î¶à limit ¸öÔªËØ£¬¶ø×îºóÄǸöÔªËؽ«°üº¬ string µÄÊ£Óಿ·Ö¡£ Èç¹û limit ²ÎÊýÊǸºÊý£¬Ôò·µ»Ø³ýÁË×îºóµÄ -limit ¸öÔªËØÍâµÄËùÓÐÔªËØ¡£ Èç¹û limit ÊÇ 0£¬Ôò»á±»µ±×ö 1¡£$str = 'one two three four';var_dump(explode(" ", $str)); //array(4) { [0]=> string(3) "one" [1]=> string(3) "two" [2]=> string(5) "three" [3]=> string(4) "four" }var_dump(explode(" ", $str, 1));//array(1) { [0]=> string(18) "one two three four" }var_dump(explode(" ", $str, -1));//array(3) { [0]=> string(3) "one" [1]=> string(3) "two" [2]=> string(5) "three" }
//½«Ò»¸öһάÊý×éµÄֵת»¯Îª×Ö·û´®
//implode ( string $glue , array $pieces )
//×¢£ºÓà glue ½«Ò»Î¬Êý×éµÄÖµÁ¬½ÓΪһ¸ö×Ö·û´®¡£$array = array('lastname', 'email', 'phone');$comma_separated = implode(",", $array);echo $comma_separated; // lastname,email,phonevar_dump(implode('hello', array())); // string(0) ""
//ʹһ¸ö×Ö·û´®µÄµÚÒ»¸ö×Ö·ûСд
// lcfirst ( string $str )
//×¢£ºÖ»ÓÐ×Ö·û´®µÄµÚÒ»¸öÊÇÓ¢ÎÄ×Öĸ²¢ÇÒ´óд²Å»áת»»echo lcfirst("ÎÒ"); //ÎÒecho lcfirst("Hello"); //hello
//½«×Ö·û´®µÄÊ××Öĸת»»Îª´óд
//ucfirst ( string $str )echo ucfirst("world"); //World
//½«×Ö·û´®ÖÐÿ¸öµ¥´ÊµÄÊ××Öĸת»»Îª´óд
//ucwords ( string $str )
//×¢£ºÈç¹ûÊ××Ö·ûÊÇ×Öĸת»»Îª´óд×Öĸecho ucwords("i am yang"); //I Am Yang
//½«×Ö·û´®×ª»¯ÎªÐ¡Ð´
//strtolower ( string $str )
//×¢£ºÈç¹û´æÔÚ×ÖĸÔòת»»ÎªÐ¡Ð´×Öĸecho strtolower("ÎÒ Is Yang"); //ÎÒ is yang
//½«×Ö·û´®×ª»¯Îª´óд
//strtoupper ( string $string )
//×¢£ºÈç¹û´æÔÚ×ÖĸÔòת»»Îª´óд×Öĸecho strtoupper("ÎÒ is yang"); //ÎÒ IS YANG
//¼ÆËã×Ö·û´®µÄ MD5 É¢ÁÐÖµ
//md5 ( string $str [, bool $raw_output = false ] )
//×¢£ºÈç¹û¿ÉÑ¡µÄ raw_output ±»ÉèÖÃΪ TRUE £¬ÄÇô MD5 ±¨ÎÄÕªÒª½«ÒÔ16×Ö½Ú³¤¶ÈµÄÔʼ¶þ½øÖƸñʽ·µ»Ø¡£ echo md5("admin"); //21232f297a57a5a743894a0e4a801fc3echo md5("admin", TRUE); //!#/)zW£¤¡ìC¡ëJJ€?
//¼ÆËã×Ö·û´®µÄ sha1 É¢ÁÐÖµ
//sha1 ( string $str [, bool $raw_output = false ] )
//×¢£ºÈç¹û¿ÉÑ¡µÄ raw_output ²ÎÊý±»ÉèÖÃΪ TRUE £¬ÄÇôsha1ÕªÒª½«ÒÔ20×Ö·û³¤¶ÈµÄÔʼ¸ñʽ·µ»Ø£¬·ñÔò·µ»ØÖµÊÇÒ»¸ö 40 ×Ö·û³¤¶ÈµÄÊ®Áù½øÖÆÊý×Ö¡£ echo sha1("admin"); //d033e22ae348aeb5660fc2140aec35850c4da997echo sha1("admin", TRUE); //D3a*?H?¦Ìf? ¨¬5¡M?¡ª
//ÒÔǧλ·Ö¸ô·û·½Ê½¸ñʽ»¯Ò»¸öÊý×Ö
//number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
//×¢£º²ÎÊý¸öÊý±ØÐëÊÇ1¡¢2¡¢4echo number_format("123.45"); //123echo number_format("123.45", 3); //123.450echo number_format(1230.45, 3, ';'); //±¨´íecho number_format(1230.45, 3, ' ', ','); //1,230 450
//·µ»Ø×Ö·ûµÄ ASCII ÂëÖµ
//int ord ( string $string )
//×¢£º¸Ãº¯ÊýÊÇ chr() µÄ»¥²¹º¯Êý¡£ ·µ»ØµÄÊÇ×Ö·û´®µÚÒ»¸ö×Ö·ûµÄASCIIÂëecho ord("ÎÒadmin"); //230
//½«×Ö·û´®½âÎö³É¶à¸ö±äÁ¿
//void parse_str ( string $str [, array &$arr ] )
//×¢£ºÈç¹û str ÊÇ URL ´«µÝÈëµÄ²éѯ×Ö·û´®£¨query string£©£¬Ôò½«Ëü½âÎöΪ±äÁ¿²¢ÉèÖõ½µ±Ç°×÷ÓÃÓò¡£$str = "http://localhost/php/string.php?a=1&b=2";parse_str($str, $arr);var_dump($arr); //array(2) { ["http://localhost/php/string_php?a"]=> string(1) "1" ["b"]=> string(1) "2" }parse_str("i am yang", $arr);var_dump($arr); //array(1) { ["i_am_yang"]=> string(0) "" }
//Öظ´Ò»¸ö×Ö·û´®
//string str_repeat ( string $input , int $multiplier )
//×¢£º·µ»Ø input Öظ´ multiplier ´ÎºóµÄ½á¹û¡£ echo str_repeat("i am yang", 2);//i am yangi am yang
//×Ó×Ö·û´®Ìæ»»
//mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
//×¢£º$count ΪÌæ»»µÄ´ÎÊý
//echo str_replace("am", "are", "i am yang"); //i are yang$arr = array('a', 'y');echo str_replace($arr, "", "i am yang"); //i m ng
//½«×Ö·û´®×ª»»ÎªÊý×é
//array str_split ( string $string [, int $split_length = 1 ] )
//×¢£º$split_length´ú±í²ð·Ö³ÉµÄÊý×éÖµµÄ×Ö·û´®µÄ³¤¶Èvar_dump(str_split("i am yang")); //½«×Ö·û´®²ð·ÖΪһ¸ö×ÖĸµÄÊý×évar_dump(str_split("i am yang", 3)); //array(3) { [0]=> string(3) "i a" [1]=> string(3) "m y" [2]=> string(3) "ang" }
//´Ó×Ö·û´®ÖÐÈ¥³ý HTML ºÍ PHP ±ê¼Ç
//string strip_tags ( string $str [, string $allowable_tags ] )
//×¢£ºÊ¹ÓÿÉÑ¡µÄµÚ¶þ¸ö²ÎÊýÖ¸¶¨²»±»È¥³ýµÄ×Ö·ûÁÐ±í¡£ echo strip_tags("<h1>i am yang ,i can <?php"); //i am yang ,i canecho strip_tags("<h1>i am yang ,i can php </h1>", "<h1>"); //<h1>i am yang ,i can php </h1>
//»ñÈ¡×Ö·û´®³¤¶È
//int strlen ( string $string )
//×¢£º×Ö·û´®Öаüº¬ÖÐÎÄʱ¼ÆË㲻׼ȷecho strlen("i am yang"); //9echo strlen("ÎÒÊÇ yang"); //11
//?²éÕÒ×Ö·û´®Ê״γöÏÖµÄλÖÃ
//mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
//×¢£º·µ»Ø needle ÔÚ haystack ÖÐÊ״γöÏÖµÄÊý×ÖλÖᣠ$offset²»ÄÜΪ¸ºÊý£¬index£¨Ë÷Òý£©´Ó0¿ªÊ¼
//strrposecho strpos("http://localhost/php/string.php", "/"); //5
//²éÕÒÖ¸¶¨×Ö·ûÔÚ×Ö·û´®ÖеÄ×îºóÒ»´Î³öÏÖ
//string strrchr ( string $haystack , mixed $needle )
//×¢£º¸Ãº¯Êý·µ»Ø×Ö·û´®µÄÒ»²¿·Ö¡£Èç¹û needle δ±»ÕÒµ½£¬·µ»Ø FALSE ¡£
//strchr => strstrecho strrchr("i am yang", "a"); //ang
//·´×ª×Ö·û´®
//string strrev ( string $string )
//×¢£ºecho strrev("i am yang"); //gnay ma i
//²éÕÒ×Ö·û´®µÄÊ״γöÏÖ
//string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
//×¢£ºfalse:²éÕÒµÄ×Ö·û´®Ïòºó½ØÈ¡£¬ÈôΪ TRUE £¬ strstr() ½«·µ»Ø needle ÔÚ haystack ÖеÄλÖÃ֮ǰµÄ²¿·Ö¡£echo strstr("i am yang yang", "am"); //am yang yang
//·µ»Ø×Ö·û´®µÄ×Ó´®
//string substr ( string $string , int $start [, int $length ] )
//×¢£º²»°üº¬$startλÖÃÉϵÄ×Ö·û£¬$startΪ¸ºÊýʱ£¬Ôò´Ó×îºó¿ªÊ¼Êý$length¸ö×Ö·û¿ªÊ¼Ïòºó½ØÈ¡echo substr("i am yang", 1); //am yangecho substr("i am yang", -2, 2); //ng
//¼ÆËã×Ö´®³öÏֵĴÎÊý
//int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )
//×¢£º¸Ãº¯Êý²»»á¼ÆËãÖصþ×Ö·û´®¡£echo substr_count("i am yang", "a"); //i am yang => 2echo substr_count("i am yang", "a", 3); // m yang => 1echo substr_count("i am yang", "a", 3, 3); //m y => 0
ÒÔÉϾÍÊDZ¾ÆªµÄÈ«²¿ÄÚÈÝ£¬¸ü¶àÏà¹Ø½Ì³ÌÇë·ÃÎÊphp±à³Ì´ÓÈëÃŵ½¾«Í¨È«Ì×ÊÓƵ½Ì³Ì£¬phpʵսÊÓƵ½Ì³Ì£¬bootstrapÊÓƵ½Ì³Ì£¡
ÒÔÉϾÍÊÇphpÖÐÓÐÄÄЩ³£ÓÃ×Ö·û´®£¿¾ÙÀý˵Ã÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢phpÖÐÎÄÍøÆäËüÏà¹ØÎÄÕ£¡