×Öu´®
×¢Òaµ¥ÒýºÅºÍË«ÒýºÅµÄÇø±ð
×¢ÒaתÒa×Öu\µÄʹÓÃ\\,\",\$
×¢ÒaʹÓÃ8½øÖÆ»o16½øÖÆ×Öu±iʾ \xf6
echo "H\xf6me";//ÐeÒª²i¿´ÊÇñÖ§³Ö´ËÀaÎÄ×Ö±aÂe
---------------------Êa³o½a¹u----------------------------------------
Home
---------------------------------------------------------------------
1.ʹÓÃprintf()ºÍsprintf()´´½¨¸ñʽ»¯µÄÊa³o
printf()Ö±½ÓÊa³oµ½Êa³o»º³aÇø
sprintf()µÄÊa³o×÷Ϊ×Öu´®µ»Ø
Èçprintf("Êa³oÄÚÈÝ %.2f\n",$PI());
ËuÓеÄת»»¹ae¶¶¼ÒÔ%¿ªÍ
Êý¾ÝÀaÐÍÓÐd-ÕuÊý,s-×Ö*u´®,f-¸¡µaÊý,b-¶þ½øÖÆ
.2ÊÇÒ»¸o¿ÉÑ¡µÄ¿i¶ÈÖ¸±e£¬Ð¡ÊýµaÓÒ±ßÊa³oʹÓÃ0Ìi³a
printf("%.2f",3.14159);
printf("%10.2f",3.14159);
printf("%.10f",3.14159);
printf("%.9s",abcdefghijklmn);
printf("%5.2f,%f,%7.3f\m",3.14159,3.14159,3.14159);
printf("%b %d %f %s \n",123,123,123,"test");
---------------------Êa³o½a¹u----------------------------------------
3.14 3.143.1415900000abcdefghi 3.14,3.141590, 3.142\m1111011 123 123.000000 test
---------------------------------------------------------------------
2.×Ö*u´®Ìi³a
string str_pad(string inputÔʼ×Ö´®, int lengthÌi¼ÓºoµÄ×ܳ¤¶È[, string paddingÒªÌi³aµÄ×Ö*u [, int pad_type]Ìi³aÀaÐÍ])
Ìi³aÀaÐÍÓÐÌi¼ÓÔÚ×o±ßSTR_PAD_LEFT£¬Ä¬ÈÏÌiÔÚÓұߣ¬Ìi³aÔÚÁ½¶ËSTR_PAD_BOTH
$index = array("one"=>1,"two"=>155,"three"=>1679);
echo "
";
echo str_pad("ÕaÊDZeÌa",50," ",STR_PAD_BOTH)."\n";
foreach($index as $inkey=>$inval)
echo str_pad($inkey,30,".").str_pad($inval,20,".",STR_PAD_LEFT)."\n";
echo "
";
---------------------Êa³o½a¹u----------------------------------------
ÕaÊDZeÌa
one..............................................1
two............................................155
three.........................................1679
---------------------------------------------------------------------
string strtolower(string subject)//ת»»ÎªÐ¡Ð´
string strtoupper(string subject)//ת»»Îª´oд
string ucfirst(string subject)//Ê××Öĸ´oд
string ucwords(string subject)//ÿ¸oµ¥´ÊÊ××Öĸ´oд
string ltrim(string subject)//È¥×o¿Õ°×
string rtrim(string subject)//È¥ÓÒ¿Õ°×
string trim(string subject)È¥×oÓÒ¿Õ°×£¬¿Õ°×°uÀ¨null,ÖƱiu£¬»»ÐÐu£¬»Ø³µuºÍ¿Õ¸ñ
string n12br(string source)//½«\n±iʾµÄ»»ÐÐuת»»Îª
±e¼Ç
3.×Ö*u´®±È½Ï
integer strcmp(sting str1,string str2) //str1´oÓÚstr2µ»Ø-1 str1СÓÚstr2µ»Ø1 str1ºÍstr2ÏaµÈµ»Ø0
integer strmcmp(sting str1,string str2,integer length) //µÚÈý¸o²ÎÊýÏÞÖÆlength¸o×ÖuµÄ±È½Ï
print strcmp("aardvark","aardwolf");
print strncmp("aardvark","aardwolf",4);
---------------------Êa³o½a¹u----------------------------------------
-10
---------------------------------------------------------------------
strcasecmp()ºÍstrncasecmp()ÊDz»Çø*Ö´oСдµÄ±È½Ïº¯Êý
4.²eÕҺͳeÈ¡×Ó×Ö*u´®
string substr(sting source,integer start[,integer length])//´Óstart¿ªÊ¼È¡length¸o×Öu
startºÍlength¿ÉÒÔʹÓøºÖµ
$var = "abcdefgh";
print substr($var,2);//´Ó0¿ªÊ¼¼ÆÊý
print substr($var,2,3);
print substr($var,-1);//´Ó×Öu´®µÄÄ(C)β¿ªÊ¼
print substr($var,-5,2);
print substr($var,-5,-2);
---------------------Êa³o½a¹u----------------------------------------
cdefgh
cde
h
de
def
---------------------------------------------------------------------
integer strpos(string haystack,string needle[,integer offset])//²eÕÒ×Ó×Öu´®µÄλÖ㬵»ØµÚÒ»´Î³oÏÖ.
integer strrpos(string haystack,string needle)//Ö»ËÑË÷µ¥¸o×Öu£¨¶a¸o×ÖuֻȡµÚÒ»¸o£(C)£¬µ»Ø×iºoÒ»´Î³oÏÖµÄË÷Òý.
»¹Óг£¼uµÄ´Ó ×Öu´®ÖгeÈ¡ÕÒµ½µÄ²¿Ö µÄº¯Êý
string strstr(string haystack,string needle)//²»ÇøÖ´oСд
string stristr(string haystack,string needle)//Çø*Ö´oСд
string strrchr(string haystack,sting needle)
*** array explode(string separator,string subject[,integer limit])//µ»ØÒ»¸o×Öu´®Êý×e
array implode(string glue,array pieces)//µ»ØÒ»¸o×Öu´®
///////////////////////////´uÂe¶Î////////////////////////////////////////
$guest = "this is a string";
$guestArray = explode(" ",$guest);
var_dump($guestArray);
sort($guestArray);
echo implode(",",$guestArray);
////////////////////////////////////////////////////////////////////////
---------------------Êa³o½a¹u----------------------------------------
array(4) { [0]=> string(4) "this" [1]=> string(2) "is" [2]=> string(1) "a" [3]=> string(6) "string" } a,is,string,this
---------------------------------------------------------------------
5.Ìae»»×ÖuºÍ×Ó×Öu´®
string substr_replace(string source,string replace,int start[,int length])