zoukankan      html  css  js  c++  java
  • php函数指定默认值的方法

    发布:JB02   来源:脚本学堂     【  
    本文介绍下,在php编程中,指定函数的默认值的方法,分享二个例子,供大家学习参考下。本文转自:http://www.jbxue.com/article/14255.html
    本节内容:

    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>
  • 相关阅读:
    mongodb 添加用户
    mongo 安装
    python 操作redis
    python 安装 redis
    redis 命令文档网址
    redis 事务
    Redis key命令
    手动卸载的vs2010
    个人封装JavaScript函数
    女学-温砚如老师的人生女学
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3456527.html
Copyright © 2011-2022 走看看