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

PHP defines a parameter with default value function instance analysis_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:03:43
Original
828 people have browsed it

PHP defines a function with default values ​​​​and analyzes the examples

This article mainly introduces php to define a function with default values ​​​​and analyzes the php parameters with examples. Friends who need tips on using functions with default values ​​can refer to them

The example of this article analyzes the usage of PHP function 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

?

1

2

3

4

5

6

7

8

9

10

11

function capitalize( $str, $each=TRUE ) {

$str = strtolower($str);

if ($each === TRUE) { $str = ucwords ($str);

} else {

$str = strtoupper($str); }

echo ("$str
");

}

capitalize("hEllo WoRld!");

capitalize("hEllo WoRld!",FALSE);

?>

1 2

3

4 5

67 8 9 10 11
function capitalize( $str, $each=TRUE ) {
$str = strtolower($str);<🎜> <🎜>if ($each === TRUE) { $str = ucwords ($str);<🎜> <🎜>} else {<🎜> <🎜>$str = strtoupper($str); }<🎜> <🎜>echo ("$str
"); } capitalize("hEllo WoRld!"); capitalize("hEllo WoRld!",FALSE); ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/968660.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/968660.htmlTechArticlephp defines a parameter with a default value function example analysis. This article mainly introduces php to define a parameter with a default value. Default value function, the example analyzes the php parameter function with default value...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template