PHP functions and PHP Functions
As follows:
<? Php // simple function show () {echo "hello" ;}show (); // function show ($ a) {echo "$ ";} show ("world"); // function with returned values show () {return "Small V, hello! ";}Echo show (); function show ($ a, $ B) {return $ a + $ B;} echo show (10, 5 ); // Variable Parameter function (special usage) function sum () {$ arr = func_get_args (); $ sum = 0; for ($ I = 0; $ I <count ($ arr); $ I ++) {$ sum + = $ arr [$ I];} echo $ sum;} sum (1, 2, 5 ); // common function echo rand (); // obtain the random number echo time (); // obtain the current timestamp echo date ("Y-m-d H: I: s ", time (); // format the display time echo strtotime ("10:00:00") // convert the time to the timestamp // string function $ s = "Small V, hello! "; $ S1 =" hello world "; echo strlen ($ s1); echo strtolower ($ s1); echo strtoupper ($ s1 ); // split string $ str = "hello | mike | nice | 159"; var_dump (explode ("|", $ str); // merge string $ arr =, 9, 6, 3]; echo implode ($ arr); // Replace the string echo substr_replace ($ str, "###", 16, 3); echo str_replace ("| ", "@", $ str); // capture the string var_dump (substr ($ str, 10, 4); // Regular Expression delimiter: /start/END ^ match start with $ match end * The expression before can appear n times + the expression before at least once? The previous expression can appear 0, 1 times {n} matches n times {n,} appears at least n times not limited to {n, m} At Least n times at most m times x | y or the meaning [abc] matches any one of the [a-z] matches any one of the numbers between a and z \ d \ S any visible character \ w any word character including underline $ s = a1b2c3d4e5; echo preg_replace ("/\ d/", "*", $ s); // replace var_dump (preg_split ("/\ d/", $ s )); // split // match the first regular type $ s = file_get_contets (); // get the content $ arr = array (); preg_match ("", $ s, $ arr);?>
The above PHP function-based operation method is all the content that I have shared with you. I hope you can give us a reference and support the help house.