PHP If语句用所有代码响应,而不是打印答案


PHP If statement responding with all code rather than printing answer

我对编程还很陌生。我正试图为我的数据库编写一段相当基本的if,elseif代码,但当它编译时,它只打印从第一个if语句到最后的代码。我已经看了好几天了,不知道哪里出了问题

<!DOCTYPE html>
<html>
<body>
<?php
$row = "A1 Header";
$compulsary = FALSE;
$mutable = TRUE;
$included = FALSE;
if ($compulsary == FALSE and $mutable == TRUE) {
        echo "<textarea style=background-color:yellow; name='"message'">Please Enter</textarea><br>";
    }
elseif ($compulsary == FALSE and $mutable == FALSE){    
        echo "'"$row"'";
        }
elseif ($compulsary == True and $mutable == True) {
    echo "<textarea style=background-color:yellow; name='"message'">Please Enter</textarea><br>";
    }
else {
    echo "'"$row"'";
    }
?>
</body>
</html>
You can do like this:  

<!DOCTYPE html>
    <html>
    <body>
    <?php
    $row = "A1 Header";
    $compulsary = FALSE;
    $mutable = TRUE;
    $included = FALSE;
    if ($compulsary == FALSE and $mutable == TRUE) {
            echo "<textarea style='background-color:yellow;' name=''"message'"'>Please Enter</textarea><br>";
        }
    elseif ($compulsary == FALSE and $mutable == FALSE){    
            echo $row;
            }
    elseif ($compulsary == TRUE and $mutable == TRUE) {
        echo "<textarea style='background-color:yellow;' name=''"message'"'>Please Enter</textarea><br>";
        }
    else {
        echo $row;
        }
    ?>
    </body>
    </html>

尝试这个

<!DOCTYPE html>
<html>
    <body>
        <?php
        $row = "A1 Header";
        $compulsary = FALSE;
        $mutable = TRUE;
        $included = FALSE;
        if ($compulsary == FALSE and $mutable == TRUE) {
            echo "<textarea style=background-color:yellow; name='"message'">Please Enter</textarea><br>";
        } elseif ($compulsary == FALSE and $mutable == FALSE) {
            echo "'".$row."'";
        } elseif ($compulsary == True and $mutable == True) {
            echo "<textarea style=background-color:yellow; name='"message'">Please Enter</textarea><br>";
        } else {
            echo "'".$row."'";
        }
        ?>
    </body>
</html>

我认为您有语法错误。试试这个:

echo "''"$row'"'";