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,……) ?求一組數(shù)據(jù)中的最大值 ? ? ? ?mixed指混合類(lèi)型(類(lèi)型不確定)
? 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)生隨機(jī)整數(shù) ? ? ?[]表示參數(shù)可有可無(wú)。
? mt_rand ? ?int mt_rand([int $min], int $max) 產(chǎn)生更好的隨機(jī)數(shù),提高效率。
日期函數(shù):time ? int ?time(void)返回當(dāng)前的時(shí)間戳。人為規(guī)定的從1970.01.01 00:00:00 到現(xiàn)在的秒數(shù)。
? date ? string ?date(日期格式[時(shí)間戳]) ? ? ? ?格式化一個(gè)本地時(shí)間/日期
? ?格式: Y 年
m 月
d ?日?
H ?時(shí)
?i ?分
?s ?秒
? strtotime ? ?int strtotime(string $time [,int $now] ) ?將任何英文文本的日期時(shí)間描述解析為時(shí)間戳。
? date_default_timezone_set(時(shí)區(qū)) 設(shè)置時(shí)區(qū)。中華人民共和國(guó)的時(shí)區(qū):"Asia/Shanghai"。// 臨時(shí)設(shè)置,永久設(shè)置就要改配置文件php.ini:date.timezone=PRC
字符串函數(shù): strlen ? ? ? ? ? ?int strlen(string $string) ? 獲取字符串長(zhǎng)度
strtolower ? ? string strtolower(string $string) ? 字符串小寫(xiě)
strtoupper ? ?string strtoupper(string $string) ?字符串全大寫(xiě)
ucfirst ? ? ? ? ??string ucfirst(string $string) ?字符串中首字母大寫(xiě)
ucwords ? ? ? ?string?ucwords(string $string) ?每個(gè)單詞的首字母大寫(xiě)
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 [,$...]]); 釋放變量
3.2 流程控制中的循環(huán)
for
for(循環(huán)條件){
? ? ?循環(huán)體!
}
while
起始條件;
while(終止條件){
? ? ? ?循環(huán)體;
? ? ? ?步長(zhǎng); ? //注意:不寫(xiě)步長(zhǎng)會(huì)陷入死循環(huán)
}
do...while
起始條件;
do{
循環(huán)體;
步長(zhǎng);
}while(終止條件);
注意:無(wú)論終止條件是不是成立,都會(huì)執(zhí)行一次。
break continue 改變循環(huán)狀態(tài)
break 終止循環(huán)
continue 結(jié)束本次循環(huán) ?循環(huán)體 ?繼續(xù)下一次循環(huán)
?
?

Outils d'IA chauds

Undress AI Tool
Images de déshabillage gratuites

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Clothoff.io
Dissolvant de vêtements AI

Video Face Swap
échangez les visages dans n'importe quelle vidéo sans effort grace à notre outil d'échange de visage AI entièrement gratuit?!

Article chaud

Outils chauds

Bloc-notes++7.3.1
éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)