PHP function Specifies a small example of a default value method _php Tutorial

Source: Internet
Author: User
The content of this section:
PHP functions Specify default values
In PHP programming, the default value is set for a custom function, and when the user calls the function, the parameter is replaced with a default value if the parameter is not assigned a value.
Example 1,
Copy CodeThe code is as follows:


<title>PHP functions Specify default values-www.jb51.net</title>


function printMe ($param = NULL)
{
Print $param;
}
PrintMe ("This is Test");
PrintMe ();
?>


Output Result:
This is test
Example of using the default value of the 2,php function parameter, set and use the default value in the PHP function parameter.
Code:
Copy the Code code as follows:


php function parameter default value-Www.jb51.net


function Textonweb ($content, $fontsize =3) {
echo "$content";
}
Textonweb ("A
", 7);
Textonweb ("AA.
");
Textonweb ("AAA.
");
Textonweb ("aaaa!
");
?>


http://www.bkjia.com/PHPjc/621698.html www.bkjia.com true http://www.bkjia.com/PHPjc/621698.html techarticle in this section: PHP functions specify default values in PHP programming, default values are set for custom functions, and when the user calls the function, the parameter is replaced with the default value if it is not given a value ...

  • 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.