<?php
function pay($price,$amount){
echo "價格: $price <br/> 數量: $amount <br/>\n";
$s=$price * $amount;
return $s;
}
?>
<html>
<title>
<body>
<?php
$price=90;
$amount=100;
$totalA=pay($price,$amount);
echo "金額: $totall <p>"; //第一次呼叫
$price=60;
$amount=50;
$totalB=pay($price,$amount); //第二次呼叫
echo "金額:$total2<p>";
$totalA+=$totalB;
echo "總金額:$total2";
?>
</body>
</html>
請問第一次呼叫己經把涵數值放進 $totall
echo 輸出 為什麼金額會在最底下
輸出結果而不是
金額價格:90
數量:100
9000
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.252.55.122
→
12/18 21:30, , 1F
12/18 21:30, 1F
※ 編輯: freebad 來自: 111.252.55.122 (12/18 23:29)
※ 編輯: freebad 來自: 111.252.55.122 (12/18 23:41)
※ 編輯: freebad 來自: 111.252.55.122
※ 編輯: freebad 來自: 111.252.55.122 (12/18 23:46)
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章