Php summary 3.0-basic functions, loops in Process Control, php3.0
3.1 basic php functions (mathematics, date, string)
Mathematical functions: max mixed max (number $ arg1, number $ arg2 ,......) Finding the maximum value in a set of data indicates the mixed type (the type is not certain)
Min mixed min (number $ arg1, number $ arg2 ,......) Returns the minimum value of a set of data.
Ceil float ceil (float $ value) rounded up
Floor float floor (float $ value) rounded down
Round float round (float $ value) Rounding
Rand int rand ([int $ min], int $ max) generates a random integer [], indicating that the parameter is 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 specified number of seconds from 00:00:00 to the present.
Date string date (date format [timestamp]) format a local time/date
Format: Y years
M month
D
H hour
I
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) sets the time zone. Time zone of the People's Republic of China: "Asia/Shanghai ". // Temporary settings. For permanent settings, you must change the configuration file php. ini: date. timezone = PRC.
String function: strlen int strlen (string $ string) to obtain the string length
Strtolower string strtolower (string $ string) string lower case
Strtoupper string strtoupper (string $ string) string all uppercase
Ucfirst string ucfirst (string $ string) string with uppercase letters
Ucwords string ucwords (string $ string) uppercase letters of each word
Strrev string strrev (string $ string) reverse string hello ---> olleh
Trim string trim (string $ string) removes spaces at the beginning and end of the string.
Str_replace mixed str_replace (mixed $ search, mixed $ replace, mixed $ subject [, int & $ count]) replace
Strpos int strpos (string $ haystack, mixed $ neddle [, int $ offset = 0 ])
Substr string substr (string $ string, int $ start [, int $ length]) intercepts a string
Md5 string mds (string $ str) string Encryption
Unset void unset (mixed $ var [, mixed $ var [, $...]); release variable
3.2 loop in Process Control
For
For (loop condition ){
Loop body!
}
While
Start condition;
While (termination condition ){
Loop body;
Step size; // Note: if you do not write the step size, it will be in an endless loop.
}
Do... while
Start condition;
Do {
Loop body;
Step size;
} While (termination condition );
Note:Execution is performed once regardless of whether the conditions for termination are true.
Break continueChange Cycle Status
Break termination cycle
Continue ends the current loop body and continues the next loop