网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2024/5/10 浏览:3 次 )

例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实现文件下载(支持中文文名)
下一篇:根据中文裁减字符串函数的php代码
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网