php筆記3.0基本函數(shù)、流程控制中的循環(huán)
Nov 16, 2016 am 10:24 AM3.1 php基本函數(shù)(數(shù)學、日期、字符串)
數(shù)學函數(shù):max ? ? ? ? mixed max(number $arg1,number $arg2,……) ?求一組數(shù)據(jù)中的最大值 ? ? ? ?mixed指混合類型(類型不確定)
? min ? ? ? ? ?mixed min(number $arg1,number $arg2,……)? ?求一組數(shù)據(jù)中的最小值
? 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ū)) 設置時區(qū)。中華人民共和國的時區(qū):"Asia/Shanghai"。// 臨時設置,永久設置就要改配置文件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) ? 反轉字符串 ? 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 [,$...]]); 釋放變量
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 終止循環(huán)
continue 結束本次循環(huán) ?循環(huán)體 ?繼續(xù)下一次循環(huán)
?
?

熱AI工具

Undress AI Tool
免費脫衣服圖片

Undresser.AI Undress
人工智能驅動的應用程序,用于創(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)