[請益] 無法顯示switch()或if內的<<<Heredoc
我想製作一個簡易的訂單系統,處理內容都在同一個php裡,使用 op 當做流程控制Flag
所以用switch($_REQUEST['op'])來做控制,當op什麼值都沒有時就到default去
顯示Heredoc裡的內容。
但是卻什麼都顯示不出來。也把switch換成 if(){}else{} 過,Heredoc部分擺在else裡
還是什麼都顯示不出來...請問有可能是什麼原因造成的,或者有其他的寫法建議嗎?
(程式預想流程:讀入php(op無值,進入default顯示表單→submit前把op改值,
表單action目標設為原php,submit後以新op值進入process程式碼。)
<?php
switch($_REQUEST['op']){
case "process":
//資料處理
$order_id = $_POST['id'];
echo "訂單者:{$order_id}";
break;
case "result":
//顯示結果(未完成)
break;
default:
//顯示表單
echo <<<FORM
<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>測試訂單</title> </head>
<body>
<form name="form1" method="post" action="test_order.php">
<label>請輸入ID:
<input type="text" name="id">
</label>
<br>請選擇你要訂購的物品:<br>
<input type="checkbox" name="goods[]" value="merchandise1, ">
merchandise 01<br>
<input type="checkbox" name="goods[]" value="merchandise2, ">
merchandise 02<br>
<input type="checkbox" name="goods[]" value="merchandise3, ">
merchandise 03<br>
<input type="hidden" name="op" value="process">
<input type="submit" value="submit">
</form>
</body>
</html>
//end of 顯示表單
FORM;
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.169.235.222
※ 編輯: emulators 來自: 218.169.235.222 (08/19 18:55)
→
08/19 19:15, , 1F
08/19 19:15, 1F
推
08/19 19:16, , 2F
08/19 19:16, 2F
推
08/19 19:22, , 3F
08/19 19:22, 3F
推
08/20 13:38, , 4F
08/20 13:38, 4F
→
08/20 13:39, , 5F
08/20 13:39, 5F
→
08/20 22:27, , 6F
08/20 22:27, 6F
→
08/20 22:28, , 7F
08/20 22:28, 7F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章