php筆記3.0基本函數(shù)、流程控制中的循環(huán)
Nov 16, 2016 am 10:24 AM3.1 php基本函數(shù)(數(shù)學(xué)、日期、字串)
數(shù)學(xué)函數(shù):max ? ? ? ? mixed max(number $arg1,number $arg2,…) ?求一組資料中的最大值 ? ? ? ?mixed指混合型別(型別不確定)
? min ? ? ? ? ?mixed min(number $arg1,number $arg2,…)? ?求一組資料中的最小值
? ceil ? ? ? ? ? float ceil(float $value) ?向上取整
? floor ? ? ? ??float floor(float $value)? 向下取整
? round ? ? ??float round(float $value)?四捨五入
? rand ? ? ? ? int rand([int $min], int $max) 產(chǎn)生隨機整數(shù) ? ? ?[]表示參數(shù)可有可無。
? mt_rand ? ?int mt_rand([int $min], int $max) 產(chǎn)生較好的隨機數(shù),提高效率。
日期函數(shù):time ? int ?time(void)傳回目前的時間戳記。人為規(guī)定的從1970.01.01 00:00:00 到現(xiàn)在的秒數(shù)。
? date ? string ?date(日期格式[時間戳]) ? ? ? ?格式化一個本地時間/日期
? ?格式: Y 年
m 月
d ?日?
H ?時
?i ?分
?s ?秒
? strtotime ? ?int strtotime(string $time [,int $now] ) ?將任何英文文字的日期時間描述解析為時間戳記。
? date_default_timezone_set(時區(qū)) 設(shè)定時區(qū)。中華人民共和國的時區(qū):"Asia/Shanghai"。 // 暫時設(shè)置,永久設(shè)定就要改設(shè)定檔php.ini:date.timezone=PRC
字串函數(shù): strlen ? ? ? ? ? ?int strlen(string $string) ? 取得字串長度
strtolower ? ? string strtolower(string $string) ? 字串小寫
strtoupper ? ?string strtoupper(string $string) ?字串全大寫
ucfirst ? ? ? ? ??string ucfirst(string $string) ?字串中縮寫
ucwords ? ? ? ?string?ucwords(string $string) ?每個字的縮寫
strrev ? ? ? ? ? ?string?strrev(string $string) ? 反轉(zhuǎn)字串 ? hello--->olleh
trim ? ? ? ? ? ? ??string trim(string $string) 去掉字串首尾的空格
str_replace ? ? mixed?str_replace(mixed $search,mixed $replace, mixed $subject [, int &$count]) ?替換
strpos ? ? ? ? ? int strpos(string $haystack, mixed $neddle[, int $offset=0]) ?找出字元首次出現(xiàn)的位置
substr ? ? ? ? ? string substr(string $string, int $start[, int $length])截取字串
md5 ? ? ? ? ? ? ?string mds(string $str) 字串加密
unset ? ? ? ? ? ?void unset(mixed $var [,mixed $var [,$...]]); 釋放變數(shù)
3.2 流程控制中的循環(huán)
for
for(循環(huán)條件){
? ? ?循環(huán)體!
}
while
起始條件;
while(終止條件){
? ? ? ?循環(huán)體;
? ? ? ?步長; ? //注意:不寫步長會陷入死循環(huán)
}
do...while
起始條件;
do{
循環(huán)體;
步長;
}while(終止條件);
注意:無論終止條件是不是成立,都會執(zhí)行一次。
break continue 改變循環(huán)狀態(tài)
break 終止迴圈
continue 結(jié)束此循環(huán) ?循環(huán)體 ?繼續(xù)下一次循環(huán)
?
?

熱AI工具

Undress AI Tool
免費脫衣圖片

Undresser.AI Undress
人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6
視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)
