PHP ×Ö·û´® С³£Ê¶

5年以前  |  阅读数:542 次  |  编程语言:PHP 

×¢Ò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])

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
贪吃蛇
文件下载
双位运算符
发送邮件
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
提取后缀名
年的日历图
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例