1

是否可以判断帖子是否只是空的,或者只是尚未发布?我知道

if($_POST['varible']!="") {
    $loginerr="";
} else  {
    $loginerr="Please check your entry.";
}

或者

if(ifempty($_POST['varible']) {
    $loginerr="Please Check your Entry.";
} else {
    $loginerr="";
}

我只是想要一种方法来判断 $_POST 是否已发送。

4

6 回答 6

2
$loginErr='';
if (!isset($_POST['variable']))
    $loginerr="Please Check your Entry.";
于 2013-10-05T04:52:18.730 回答
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

 }
于 2013-10-05T04:56:48.377 回答
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.";
}
于 2013-10-05T04:53:06.097 回答
0

试试这个代码

if(empty($_POST['varible']))
{
    $loginerr="Please Check your Entry.";
} 
else 
{
    $loginerr = "";
}
于 2013-10-05T04:51:52.030 回答
0

使用emptyPHP 中的函数

if(empty($_POST['varible'])) {
    $loginerr = "Please Check your Entry.";
 } else {
    $loginerr = "";
 }

isset函数

if(!isset($_POST['varible'])) {
    $loginerr = "Please Check your Entry.";
 } else {
    $loginerr = "";
 }
于 2013-10-05T04:52:02.450 回答
0
<?php
//save it in a variable
$variable = $_POST['variable'];
//now check
if(empty($variable )) {

echo "The field was empty";

}
else
{
//whatever you want
}
?>
于 2013-10-05T05:11:25.227 回答