Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-13 17:18:06
Original
970 people have browsed it

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"...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template