Home > Backend Development > PHP Tutorial > php指定函数参数默认值示例代码_php实例

php指定函数参数默认值示例代码_php实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 08:52:34
Original
838 people have browsed it

例1

复制代码 代码如下:



php函数指定默认值-www.jb51.net


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



输出结果:
This is test

例2 php函数参数默认值的使用范例,php函数参数中设置和使用默认值。

复制代码 代码如下:


 
  php函数参数默认值 - www.jb51.net
 
 
    function textonweb ($content, $fontsize=3){
     echo "$content";
  }
  textonweb ("A
", 7);
  textonweb ("AA.
");
  textonweb ("AAA.
");
  textonweb ("AAAA!
");
  ?>
 
 
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
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