是否可以判断帖子是空的还是尚未发布?我知道
if($_POST['varible']!="") {
$loginerr="";
} else {
$loginerr="Please check your entry.";
}
或
if(ifempty($_POST['varible']) {
$loginerr="Please Check your Entry.";
} else {
$loginerr="";
}
我只想要一种方法,判断是否已发送$ _POST。
答案 0 :(得分:2)
$loginErr='';
if (!isset($_POST['variable']))
$loginerr="Please Check your Entry.";
答案 1 :(得分:2)
PHP isset用于检查数组中存在的行。 empty用于检查数组值。所以在这里,如果条件更好,我们可以使用这两个。
if(isset($_POST['vaiable']) && !empty($_POST['vaiable'])){
//Here all the condition is satisfied and the $_POST['vaiable'] definitely have some value
}
答案 2 :(得分:1)
要检查的语法是
if(isset($_POST['vaiable'])){code goes here}
要检查帖子是否为空,您可以按照以下语法进行检查
If(empty($_POST['vaiable'])){code goes here}
if(!empty($_POST['varible'])) {
$loginerr="";
} else {
$loginerr="Please check your entry.";
}
答案 3 :(得分:0)
试试此代码
if(empty($_POST['varible']))
{
$loginerr="Please Check your Entry.";
}
else
{
$loginerr = "";
}
答案 4 :(得分:0)
使用PHP中的empty
函数
if(empty($_POST['varible'])) {
$loginerr = "Please Check your Entry.";
} else {
$loginerr = "";
}
或isset
函数
if(!isset($_POST['varible'])) {
$loginerr = "Please Check your Entry.";
} else {
$loginerr = "";
}
答案 5 :(得分:0)
<?php
//save it in a variable
$variable = $_POST['variable'];
//now check
if(empty($variable )) {
echo "The field was empty";
}
else
{
//whatever you want
}
?>