PHP functions and PHP Functions

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.