通过if语句比较空数据


Comparing null data through if statement

我有麻烦比较一个集合变量为null。我的代码运行为

.......some code
echo "Question1 is" . $q1. "is Question-1";
?>
<html>
<head>  
<form method="post" method="post" action="jobprocess.php">
<?
    if($q1!="")
    { ?>
        <h3> Answer the below simple questions related to the job and apply </h3>
        <div align="center">
        <input type="text" name="q1" required placeholder="<?php echo $q1;?>"><br>
    <? } ..... some more code

结果显示为

Question1 isis Question-1

回答以下与工作相关的简单问题并申请

(文本框)

虽然第一行确认变量q1=",但我不明白为什么要输入!$q1="循环

谢谢你的耐心在我发布这篇文章之前,我已经经历了===null和empty($var)的用法,我无法找出我的代码

有什么问题

尝试使用if(!is_null($q1))代替您的条件