The content of this section:
PHP functions Specify default values
In PHP programming, a default value is set for a custom function, and when the user calls the function, the parameter is replaced with the default value if the parameter is not assigned a value.
Example 1,
Copy Code code as follows:
The <title>php function specifies the default value-www.jb51.net</title>
<body>
<?php
function Printme ($param = NULL)
{
Print $param;
}
Printme ("This is Test");
Printme ();
?>
</body>
Output results:
This is test
Example 2,php the use of default values for function parameters, set and use default values in PHP function parameters.
Code:
Copy Code code as follows:
<title>php function parameter default value-www.jb51.net</title>
<body>
<?php
function Textonweb ($content, $fontsize =3) {
echo "<font size= $fontsize > $content </font>";
}
Textonweb ("A <br/>", 7);
Textonweb ("aa.<br/>");
Textonweb ("AAA"). <br/> ");
Textonweb ("aaaa! <br/> ");
?>
</body>