html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

php指定函数参数默认值示例代码_php实例_脚本之家

[ ] 已经帮助:人解决问题

例1

复制代码 代码如下:

<html>
<head>
<title>php函数指定默认值-www.jbxue.com</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.jbxue.com</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>

(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助