如何在php变量中存储html标签

时间:2013-07-29 17:54:40

标签: php html variables

好的,所以即时制作一个登录系统,出于某种原因,如果输入这样的内容,我会发现没有回显或打印的问题以及以下脚本,显示本身可以帮助任何人。

<?PHP $form = '
 <form method="POST" action="login.php">
<table>
    <tr>
        <td>Username:<td>
        <td><input type="text" name="user"><td>
    </tr>
    <tr>
        <td>Password:<td>
        <td><input type="password" name="password"><td>
    </tr>
    <tr>
        <td><td>
        <td><input type="submit" name="loginbtn" value="Login"><td>
    </tr>
    <tr>
        <td><a href="register.php">Register</a><td>
        <td><a href="forgotpass.php">Forgoten Password</a><td>
    </tr>
</table>
</form>'
;
?>

1 个答案:

答案 0 :(得分:2)

<?php //Some PHP Code if necessary 
if(true) { //Any html between this brace and the next brace will be included

?>

<form method="POST" action="login.php">
    <table>
        <tr>
            <td>Username:<td><td>
            <input type="text" name="user">
            <td>
        </tr>
        <tr>
            <td>Password:<td><td>
            <input type="password" name="password">
            <td>
        </tr>
        <tr>
            <td><td><td>
            <input type="submit" name="loginbtn" value="Login">
            <td>
        </tr>
        <tr>
            <td><a href="register.php">Register</a><td><td><a href="forgotpass.php">Forgoten Password</a><td>
        </tr>
    </table>
</form>
<?php
} //End of if statement.
else { //This won't be shown, because the if statement is always true
?>
<div>
    This is not displayed
</div>

<?php
}
?>