新手一枚,代碼如下,把post 改成 get 就沒問題,但如果是post 就會提示
Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3
add.html
Title
add.php
回複內容:
新手一枚,代碼如下,把post 改成 get 就沒問題,但如果是post 就會提示
Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3
add.html
Title
add.php
我也是類似的問題,只有一種可能,就是你得phpstrom配置的連接埠與phpinfo()連接埠不符。先看一下phpinfo()?>的連接埠在哪裡比如localhost,那麼就配置phpstrom-》Tools-》Dployment-》Configuration-》
建立比如Name=localhost,然後設定Web sever root url為http://localhost,連接埠與phpinfo()連接埠一致即可
php.ini 中配置 enable_post_data_reading 為 On, 這樣才會自動將 POST 資料填入 $_POST 數組中。
; Whether PHP will read the POST data.; This option is enabled by default.; Most likely, you won't want to disable this option globally. It causes $_POST; and $_FILES to always be empty; the only way you will be able to read the; POST data will be through the php://input stream wrapper. This can be useful; to proxy requests or to process the POST data in a memory efficient fashion.; http://php.net/enable-post-data-reading; enable_post_data_reading = Off
判斷是否輸入a和b的值,應該使用:
isset($_POST['a']) && isset($_POST['b']
你的寫法在a或b輸入0值時,不會走相加分支。
列印 $_REQUEST
數組,
如果查驗是否有資料POST過來,如果沒有確定的條件下,推薦在業務處理前先進行列印資料。
上面可以直接
var_dump($_POST);
看下是否有值。
post有好幾種方式,你看你是什麼方式提交的?
php配置問題吧