Home  >  Article  >  Backend Development  >  PHP specifies the default value of function parameter sample code_PHP tutorial

PHP specifies the default value of function parameter sample code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:06928browse

Example 1

Copy code The code is as follows:



PHP function specifies default value - www.jbxue.com


function printMe($param = NULL)
{
print $param;
}
printMe("This is test");
printMe();
?>



Output result:
This is test

Example 2 Example of using default values ​​of php function parameters, setting and using default values ​​in php function parameters.

Copy code The code is as follows:



< ;title>php function parameter default value - www.jbxue.com


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


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621702.htmlTechArticleExample 1 Copy the code The code is as follows: html head titlephp function specifies the default value-www.jbxue.com/title /head body ?php function printMe($param = NULL) { print $param; } printMe("This is test"...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn