Maison  >  Article  >  développement back-end  >  php指定函数参数默认值示例代码_php实例

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

WBOY
WBOYoriginal
2016-05-17 08:52:34773parcourir

例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!
");
  ?>
 
 
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn