PHP的function 函數

這是我作PHPfunction函數的一點筆記:php

 <body>ide

<?php
function writeMyName($fname)
  {
  echo $fname . " Yang.<br />";
  }
 
echo "My name is ";
writeMyName("David");
 
echo "My name is ";
writeMyName("Mike");
 
echo "My name is ";
writeMyName("John");
//輸出不一樣的名字,但姓是相同的:
?>
 
<hr color="#FF0000">
 
 
<?php
function writeMyName1($fname,$punctuation)
  {
  echo $fname . " Yang" . $punctuation . "<br />";
  }
 
echo "My name is ";
writeMyName1("David",".");
 
echo "My name is ";
writeMyName1("Mike","!");
 
echo "My name is ";
writeMyName1("John","...");
?>
 
 
<hr color="#FF0000">
<?php
function add($x,$y)
  {
  $total = $x + $y;
  return $total;
  }
 
echo "1 + 16 = " . add(1,16);
//PHP 函數 - 返回值,函數也能用於返回值
?>
 
 
</body>
相關文章
相關標籤/搜索