[請益] 變數在不同檔之間傳遞

看板PHP作者 (彈吉他好快樂)時間13年前 (2012/12/21 23:31), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
看了許多書 變數作用域若要變大 要用global 但好像只限在同一檔內 不同檔該怎麼辨呢?只能用form嗎?如果好幾個檔都要存取同一個變數怎麼辨? 檔名:test1.php <form action="test2.php" method="post"> <?php $a = 111; ?> <input type="submit" value="go"> </form> 檔名:test2.php <?php global $a; echo "this is test2 <br>"; echo "a = $a <br>";?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.218.5.219

12/21 23:41, , 1F
session or include
12/21 23:41, 1F

12/23 11:04, , 2F
- - $_POST or $_GET 你都用form了..怎不用input送..
12/23 11:04, 2F
文章代碼(AID): #1Gr83Z4A (PHP)
文章代碼(AID): #1Gr83Z4A (PHP)