欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php函數(shù)指定默認值方法的小例子

 更新時間:2013年12月04日 17:21:54   作者:  
本文介紹下,在php編程中,指定函數(shù)的默認值的方法,分享二個例子,供大家學(xué)習(xí)參考下

本節(jié)內(nèi)容:
php函數(shù)指定默認值
在php編程中,為自定義函數(shù)設(shè)定默認值,當(dāng)用戶調(diào)用該函數(shù)時,如果不給參數(shù)指定值,參數(shù)會用默認值頂替。
例1,

復(fù)制代碼 代碼如下:

<html>
<head>
<title>php函數(shù)指定默認值-www.dbjr.com.cn</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
   print $param;
}
printMe("This is test");
printMe();
?>
</body>
</html>

輸出結(jié)果:
This is test
例2,php函數(shù)參數(shù)默認值的使用范例,php函數(shù)參數(shù)中設(shè)置和使用默認值。
代碼:

復(fù)制代碼 代碼如下:

<html>
  <head>
  <title>php函數(shù)參數(shù)默認值 - www.dbjr.com.cn</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>

相關(guān)文章

最新評論