源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php函数指定默认值方法的小例子

  • 时间:2020-03-13 14:43 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php函数指定默认值方法的小例子
本节内容: php函数指定默认值 在php编程中,为自定义函数设定默认值,当用户调用该函数时,如果不给参数指定值,参数会用默认值顶替。 例1,
[u]复制代码[/u] 代码如下:
<html> <head> <title>php函数指定默认值-www.1sucai.cn</title> </head> <body> <?php function printMe($param = NULL) {    print $param; } printMe("This is test"); printMe(); ?> </body> </html>
输出结果: This is test 例2,php函数参数默认值的使用范例,php函数参数中设置和使用默认值。 代码:
[u]复制代码[/u] 代码如下:
<html>   <head>   <title>php函数参数默认值 - www.1sucai.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>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部