PHP Notes 3.0 basic functions and loops in process control
Nov 16, 2016 am 10:24 AM3.1 php basic functions(math, date, string)
Mathematical function: max mixed max(number $arg1,number $arg2,...) Find the maximum value in a set of data Mixed refers to mixed type (undefined type)
min ? ? ? ? ? ? mixed min(number $arg1,number $arg2,...) ? Find the minimum value in a set of data
ceil ? ? ? ? ? ? float ceil(float $value) Round up
floor float floor(float $value) Round down
round ? float round(float $value) Rounding
rand int rand([int $min], int $max) generates a random integer [] indicating that the parameters are optional.
mt_rand int mt_rand([int $min], int $max) generates better random numbers and improves efficiency.
Date function: time int time(void) returns the current timestamp. The artificially specified number of seconds from 1970.01.01 00:00:00 to the present.
date string date(date format [timestamp]) Format a local time/date
Format: Year Y
m month
d day
H time
i points
s seconds
strtotime int strtotime(string $time [,int $now] ) Parses the date and time description of any English text into a timestamp.
date_default_timezone_set (time zone) Set the time zone. Time zone of the People's Republic of China: "Asia/Shanghai". // For temporary settings, you need to change the configuration file php.ini for permanent settings: date.timezone=PRC
String function: strlen int strlen(string $string) Get the length of the string
strtolower string strtolower(string $string) string lowercase
strtoupper string strtoupper(string $string) string in all uppercase
ucfirst ? ? ? ? ? ? string ucfirst(string $string) Capitalize the first letter in the string
ucwords string ucwords(string $string) The first letter of each word is capitalized
strrev ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?.?
trim ? ? ? ? ? ? ? ? ? string trim(string $string) removes the spaces at the beginning and end of the stringstr_replace mixed str_replace(mixed $search,mixed $replace, mixed $subject [, int &$count]) Replacement
strpos int strpos(string $haystack, mixed $neddle[, int $offset=0]) Find the position where the character first appears
substr string substr(string $string, int $start[, int $length]) intercepts the string
md5 ? ? ? ? ? ? ? ? string mds(string $str) String encryption
unset ? ? ? ? ? ? ? ? void unset(mixed $var [,mixed $var [,$...]]); Release variables
3.2 Loops in process control
for
for(loop condition){Loop body!
}
while
Starting conditions;while(termination condition){
loop body;
Step size; //Note: If you don’t write the step size, you will fall into an infinite loop
}
do...while
Starting conditions;do{
Loop body;
step size;
}while(termination condition);
Note: No matter whether the termination condition is true or not, it will be executed once.
break continue Change loop status
break terminates the loop
continue ends this loop loop body continues the next loop

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
