首页 > Web开发 > 详细

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

时间:2016-01-30 08:02:21      阅读:247      评论:0      收藏:0      [点我收藏+]

例1

复制代码 代码如下:

<html>
<head>
<title>php函数指定默认值-www.jb51.net</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
   print $param;
}
printMe("This is test");
printMe();
?>

</body>
</html>

输出结果:
This is test

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

复制代码 代码如下:

<html>
  <head>
  <title>php函数参数默认值 - www.jb51.net</title>
  </head>
  <body>
  <?php
  function textonweb ($content, $fontsize=3){
     echo "<font SIZE=$fontsize>$content</font>";
  }
  textonweb ("A <br />", 7);
  textonweb ("AA.<br />");
  textonweb ("AAA. <br />");
  textonweb ("AAAA! <br />");
  ?>
  </body>
  </html>

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

原文:http://www.jb51.net/article/44103.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!