PHP在日志中写入此错误:"注意:使用未定义的常量".
日志错误:
PHP Notice: Use of undefined constant department - assumed 'department' (line 5)
PHP Notice: Use of undefined constant name - assumed 'name' (line 6)
PHP Notice: Use of undefined constant email - assumed 'email' (line 7)
PHP Notice: Use of undefined constant message - assumed 'message' (line 8)
Run Code Online (Sandbox Code Playgroud)
相关代码行:
$department = mysql_real_escape_string($_POST[department]);
$name = mysql_real_escape_string($_POST[name]);
$email = mysql_real_escape_string($_POST[email]);
$message = mysql_real_escape_string($_POST[message]);
Run Code Online (Sandbox Code Playgroud)
它是什么意思,我为什么看到它?
不知道更好的标题,但这是我的代码.
我有类用户在实例化时检查表单数据,但我得到以下错误/通知:
Notice: Use of undefined constant username - assumed 'username' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
Notice: Use of undefined constant password - assumed 'password' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
Notice: Use of undefined constant passwordc - assumed 'passwordc' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
... and so on for every defined variable in user class.
Run Code Online (Sandbox Code Playgroud)
这是用户类:
class User {
function __construct(){
$test = 'blah';
$username; $password; $passwordc; $name; $surname; $address;
$this->checkInput(array(username=>20, password=>20, passwordc=>20, name=>20, surname=>40, address=>40));
}
//array(formName=>CharacterLimit)
private function …Run Code Online (Sandbox Code Playgroud)