php specifies the default values for the function parameters in the sample code

  • 2020-12-05 17:08:34
  • OfStack

Case 1


<html>
<head>
<title>php The function specifies the default value -www.ofstack.com</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
   print $param;
}
printMe("This is test");
printMe();
?>

</body>
</html>

Output results:
This is test

Example 2 An example of using default values for php function arguments, set and use default values in php function arguments.


<html>
  <head>
  <title>php Default values for function parameters  - www.ofstack.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>


Related articles: