有没有办法缩写以下内容?
if ($chk == 1 || $chk == 3 || $chk == 5 || $chk == 7){
do some stuff
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我是否认为下面的陈述将验证$ a是'1'还是'0',而$ b是'x'或'y'
if ($a == '1' && $b == 'x' || $b == 'y')
Run Code Online (Sandbox Code Playgroud)
或者我必须更具体,即
if ($a == '1' && $b == 'x' || $a == '1' && $b == 'y')
Run Code Online (Sandbox Code Playgroud) 我正在尝试根据会话数据为html注册表单中的文本框填写默认的"值"字段.
如果用户在我的注册表单上发生任何错误,则会将其发回,我希望尽可能多地填写他们的数据,而不是将其发送回普通表单以重新开始.
这是我的处理程序脚本检查:
// Let's get the text from the form,.
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$password_check = mysql_real_escape_string($_POST['pwcheck']);
$email = mysql_real_escape_string($_POST['email']);
$spam_check = mysql_real_escape_string($_POST['checkit']); // spam check
$IP = $_SERVER['REMOTE_ADDR']; // log their ip
// set up some session data for mnistakes or spam or errors
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
// check for empty info
if ($username == NULL || $username == '') { // no username set
header ("Location: register.php?p=un"); die;
}
if ($password == …Run Code Online (Sandbox Code Playgroud)