Home > Backend Development > PHP Tutorial > PHP defines a function instance analysis with a parameter with a default value, default value instance analysis_PHP tutorial

PHP defines a function instance analysis with a parameter with a default value, default value instance analysis_PHP tutorial

WBOY
Release: 2016-07-13 10:03:38
Original
887 people have browsed it

PHP defines a function parameter with a default value and analyzes the example. Default value example analysis

This article analyzes the usage of a function in PHP that defines a parameter with a default value. Share it with everyone for your reference. The specific analysis is as follows:

PHP function parameters can specify default values. After specifying the default value, if you do not assign a value to the parameter when calling, the parameter will use the default value

<&#63;php
function capitalize( $str, $each=TRUE ) {
 $str = strtolower($str);
 if ($each === TRUE) {   $str = ucwords ($str);
 } else {
   $str = strtoupper($str); }
 echo ("$str <br />");
}
capitalize("hEllo WoRld!");
capitalize("hEllo WoRld!",FALSE);
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/968267.htmlTechArticlephp defines a parameter with a default value example analysis, default value example analysis This article provides an example analysis of php defining a Function usage with parameters with default values. Share it with everyone for your reference...
Related labels:
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