[RexTeam]php簡單字串函數說明與使用方法
pocketmine吧
全部回复
仅看楼主
level 11
RexRed6802 楼主
相信大家在編寫插件時~
一定常常遇到不知道字串函數的問題
想是不知如何計算字串文字等等的…
所以今天發個教學來向大家介紹些簡單的字串函數吧!
[笑眼][笑眼][笑眼][笑眼][笑眼][笑眼][笑眼][笑眼][笑眼][笑眼]
10個表情幣~
申精申精
2016年04月15日 14点04分 1
level 11
RexRed6802 楼主
1-1字串的書寫格式
2016年04月15日 14点04分 2
level 11
RexRed6802 楼主
字串大多必須被包含在一對 單引號 ` ' 或"
2016年04月15日 14点04分 3
level 6
围观
2016年04月15日 14点04分 4
level 11
RexRed6802 楼主
[爱心]重點
如果在' ' 裡面的字元需要用到 '則可以這樣使用
$example = 'Rex\'s plugins';
必須在 ' 前面加上\
2016年04月15日 14点04分 5
$example = "Rex's plugins"; [滑稽]
2016年04月16日 20点04分
回复 kevin1234562 :[滑稽]
2016年04月17日 02点04分
level 11
RexRed6802 楼主
[彩虹]補充
跳脫字元
\'顯示 '
\$顯示$
\"顯示"
\\顯示\
\n換行
2016年04月15日 14点04分 6
level 11
RexRed6802 楼主
1-2常用字串函數
2016年04月15日 14点04分 7
level 11
RexRed6802 楼主
1. str_replace
格式 str_replace("被取代字串","取代字串","來源字串");
$被取 = "hi";
$取 = "hello";
$來源 = "hi boys!";
$example = str_replace($被取,$取,$來源);
$event->getPlayer()->sendMessage("$example");
2016年04月15日 14点04分 8
回复 qq505916481 :hello boys
2016年04月20日 13点04分
level 11
RexRed6802 楼主
2.str_repeat()
用來重複輸入某一字串特定次數
格式 str_repeat("字串",重複數);
$example = "渲紅帥哥"
$example2 = str_repeat($example,10);
輸出結果為:渲紅帥哥渲紅帥哥渲紅帥哥…………(共10次)
2016年04月15日 14点04分 10
level 11
RexRed6802 楼主
3.ctype_digit()
用來檢測該字串是否都為數字
格式 ctype_digit("字串");
用法:
if(ctype_digit($mes)){
$e->setCanCelled();
return $p->sendMessage("§c[ RexCraft ]密碼強度太弱,至少要有一個英文");
}
2016年04月15日 14点04分 11
level 11
RexRed6802 楼主
明天繼續睡覺去
2016年04月15日 14点04分 12
level 12
水一发 昨天还拿你的插件拆来学习的233[吐舌]
2016年04月15日 16点04分 13
level 10
已收藏赞[滑稽]
2016年04月15日 17点04分 14
level 7
[滑稽]谢谢楼主 收藏了 。养肥了看
2016年04月15日 17点04分 16
level 9
PHP从入门到放弃第二章2.7
2016年04月16日 03点04分 17

2016年04月16日 04点04分
1 2 尾页