1. the sys_getloadavg () function sys_getloadavt () can obtain the system load. This function returns an array containing three elements, each representing the average load of the system in the past 1, 5, and 15 minutes. It is better to let the server go down due to excessive load on the system... SyntaxHighlighter. all
1. sys_getloadavg () function
Sys_getloadavt () can obtain the system load. This function returns an array containing three elements, each representing the average load of the system in the past 1, 5, and 15 minutes.
Instead of letting the server go down due to excessive load, it is better to take the initiative to die a script when the system load is very high. sys_getloadavg () is used to help you implement this function. But unfortunately, this function is invalid in windows.
2. pack () function
Pack () can convert a 32-bit hexadecimal string returned by md5 () to a 16-bit binary string, saving storage space.
3. cal_days_in_month ()
Cal_days_in_month () returns the total number of days in a specified month.
4. _ () function
WordPress developers often see this function as well as _ e (). These two functions have the same functions and can be used in combination with the gettext () function to implement multilingual website operations. For more information, see the relevant section of the PHP Manual.
5. get_browser () function
Before sending the page, check what your browser can do? Get_browser () can obtain the browser type and functions supported by the browser. However, you need a php_browscap.ini file to provide a reference file for the function.
Note that this function is based on the general features of the browser. For example, if the user closes the browser's support for JavaScript, the function cannot know this. However, this function is very accurate in determining the browser type and OS platform.
6. debug_print_backtrace () function
This is a function used for debugging and can help you find logical errors in the code. To understand this function, let's look at an example:
$ A = 0;
Function iterate (){
Global $;
If ($ a <10)
Recur ();
Echo $ a. ",";
}
Function recur (){
Global $;
$ A ++;
// How did I get here?
Echo "\ n ";
Debug_print_backtrace ();
If ($ a <10)
Iterate ();
}
Iterate ();
# OUTPUT:
#0 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#1 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 25]
#0 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#1 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 21]
#2 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#3 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 25]
#0 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#1 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 21]
#2 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#3 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 21]
#4 recur () called at [C: \ htdocs \ php_stuff \ index. php: 8]
#5 iterate () called at [C: \ htdocs \ php_stuff \ index. php: 25]
7. metaphone () function
This function returns the metaphone value of a word. words with the same pronunciation have the same metaphone value. that is to say, this function can help you determine whether the two words have the same pronunciation. However, it is invalid for Chinese characters...
8. natsort () function
Natsort () can sort an array by natural sorting. let's look at an example:
$ Items = array (
"100 apples", "5 apples", "110 apples", "55 apples"
);
// Normal sorting:
Sort ($ items );
Print_r ($ items );
# Outputs:
# Array
#(
# [0] = & gt; 100 apples
# [1] = & gt; 110 apples
# [2] => 5 apples
# [3] => 55 apples
#)
Natsort ($ items );
Print_r ($ items );
# Outputs:
# Array
#(
# [2] => 5 apples
# [3] => 55 apples
# [0] = & gt; 100 apples
# [1] = & gt; 110 apples
#)
9. levenshtein () function
Levenshtein () tells you the "distance" between two words ". It tells you how many letters need to be inserted, replaced, and deleted if you want to change one word to another.
Let's look at an example:
$ Dictionary = array (
"Php", "javascript", and "css"
);
$ Word = "japhp ";
$ Best_match = $ dictionary [0];
$ Match_value = levenshtein ($ dictionary [0], $ word );
Foreach ($ dictionary as $ w ){
$ Value = levenshtein ($ word, $ w );
If ($ value <$ match_value ){
$ Best_match = $ w;
$ Match_value = $ value;
}
}
Echo "Did you mean the '$ best_match' category ?";
10. glob () function
Glob () makes you think it is silly to use opendir (), readdir () and closedir () to find files.
Foreach (glob ("*. php") as $ file)
Echo "$ file \ n ";
From lsoftwolf blog