问题描述
当我输出此代码时,
23 if(!isset($_POST['user'])) { 24 $user = $_POST['user']; 25 $user2 = $user; 26 $pass[0] = $_POST['password']; 27 $pass[1] = $_POST['password2']; 28 $email[0] = $_POST['email']; 29 $email[1] = $_POST['email2']; 30 $agree = $_POST['agreed']; 31 $reprint['user'] = $user; 32 $reprint['password'] = $pass[0]; 33 $reprint['email'] = $email[0]; 34 $reprint['agree'] = $agree;
它返回
Notice: Undefined index: user in C:\Program Files\EasyPHP-5.3.6.0\www\Arena\create_account.inc on line 24 Notice: Undefined index: password in C:\Program Files\EasyPHP-5.3.6.0\www\Arena\create_account.inc on line 26 Notice: Undefined index: password2 in C:\Program Files\EasyPHP-5.3.6.0\www\Arena\create_account.inc on line 27 Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.6.0\www\Arena\create_account.inc on line 28 Notice: Undefined index: email2 in C:\Program Files\EasyPHP-5.3.6.0\www\Arena\create_account.inc on line 29
请注意,第23行没有错误,因此isset()始终返回true.实际上,所有我的$ _POST []都没有设置任何错误.您可能无法重现此内容.可能只有EasyPHP.我现在使用的是最新的EasyPHP,带有PHP 5.3.6 VC9.我一直在所有版本的EasyPHP上都遇到此问题...因此,我不确定是否存在更好的"语法或防止EasyPHP显示这些错误的方法.
Note that there is no error for line 23, so isset() always returns true; I don't get any error when all my $_POST[] are actually set. You might not be able to reproduce this; it may be only EasyPHP. I'm on the latest EasyPHP right now, with PHP 5.3.6 VC9. I've always had this problem with all versions of EasyPHP... So I'm not sure if there is a "better" syntax or a way to prevent EasyPHP from displaying these errors.
推荐答案
您是说是否已设置> .尝试删除否定运算符!.
You are saying if $_POST['user'] has not been set. Try removing the negation operator !.
// if user key has *not* been set if(!isset($_POST['user'])) { $user = $_POST['user']; // undefined index because there is no 'user' key if(isset($_POST['user'])) { $user = $_POST['user']; // no problems here
这篇关于if(!isset($ _ POST ["user"]])被忽略并返回未定义索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!