PHP骰子函数

PHP骰子函数,php,html,echo,die,Php,Html,Echo,Die,我如何使用php die函数仅停止加载某些div?我知道它可能不会和die完全一样,但是我如何才能停止只加载特定的div?所以我不希望加载learn col和col last,而是希望加载div id条。另外,如何使if语句中的H2标记不应用于else语句中的表 <html> <body> <div id="header"> <div id="site"> <h1><a href="#">site</a&

我如何使用php die函数仅停止加载某些div?我知道它可能不会和die完全一样,但是我如何才能停止只加载特定的div?所以我不希望加载learn col和col last,而是希望加载div id条。另外,如何使if语句中的H2标记不应用于else语句中的表

<html>
<body>



<div id="header">
<div id="site">
    <h1><a href="#">site</a></h1>
    </div>

   <div id="menuholder">
    <ul id="menu">
        <li><a href="index.html">Home</a></li>
        <li class="active"><a href="about.php">about application</a></li>
        <li><a href="#">register</a></li>
        <li><a href="#">contact</a></li>
    </ul>
    </div>


</div>

<div id="teaser">
    <div class="wrap">
        <div id="image"></div>
        <div class="box">

<?php
session_start ();
if (isset($_SESSION['username']))
echo "<h2>Welcome, ".$_SESSION['username']."!</h2>";
else
die("You must be logged in to view this page. 
Register to gain access to learn more about the application.    
<form action='login.php' method='POST'>
<table>
<tr><td>Username: </td><td><input type='text' name='username'/></td><td>Password: </td> <td>              <input type='password' name='password'/></td> <td><input type='submit'  name='submit' value='Login'/></td></tr>
</table>
</form>
");

?>


            <p>Information about the application would go here</p>

        </div>

    </div>
</div>

<div id="bar">
    <div class="wrap">

    </div>
</div>



<div class="wrap">
    <div class="col">
        <h3>Learn <span class="red">More</span></h3>
        <p>More info </p>
    </div>
    <div class="col">
        <h3>User <span class="red">Statistics</span></h3>
        <p>More info</p>
    </div>
    <div class="col last">
        <h3>About <span class="red">Phapsy</span></h3>
        <p>More info</p>

    </div>
</div>

<div id="footer">
    <p class="right">Contact: </p>
</div>

在else部分,只需使用echo和exit显示您想要显示的任何文本即可。您不需要死。

在else部分中,只需使用echo和exit显示您想要显示的任何文本即可。你不需要死。

你不能。die向PHP指示停止进一步处理

然而,这将起作用:

<?php
session_start ();
if (isset($_SESSION['username'])) {
    echo "<h2>Welcome, ".$_SESSION['username']."!</h2>";
    $auth = true;
} else {
    $auth = false; // Show the following HTML
?>
You must be logged in to view this page. 
Register to gain access to learn more about the application.    
<form action='login.php' method='POST'>
<table>
<tr><td>Username: </td><td><input type='text' name='username'/></td><td>Password: </td> <td>              <input type='password' name='password'/></td> <td><input type='submit'  name='submit' value='Login'/></td></tr>
</table>
</form>
<?php } // End ?>
然后在其他地方

<?php if ( $auth == true ) { // Display this HTML only if authenticated ?>
    <div class="col last">
        <h3>About <span class="red">Phapsy</span></h3>
        <p>More info</p>

    </div>
<?php } // End ?>
你不能。die向PHP指示停止进一步处理

然而,这将起作用:

<?php
session_start ();
if (isset($_SESSION['username'])) {
    echo "<h2>Welcome, ".$_SESSION['username']."!</h2>";
    $auth = true;
} else {
    $auth = false; // Show the following HTML
?>
You must be logged in to view this page. 
Register to gain access to learn more about the application.    
<form action='login.php' method='POST'>
<table>
<tr><td>Username: </td><td><input type='text' name='username'/></td><td>Password: </td> <td>              <input type='password' name='password'/></td> <td><input type='submit'  name='submit' value='Login'/></td></tr>
</table>
</form>
<?php } // End ?>
然后在其他地方

<?php if ( $auth == true ) { // Display this HTML only if authenticated ?>
    <div class="col last">
        <h3>About <span class="red">Phapsy</span></h3>
        <p>More info</p>

    </div>
<?php } // End ?>
使用if块:

<?php if($stuff): ?>
    <div></div>
<?php endif; ?>
死亡是一个句号;有很多方法可以拦截它,但不是方便的方法。在稍微不同的情况下,return可能会执行您需要的操作,因为它只退出当前函数或文件。

使用if块:

<?php if($stuff): ?>
    <div></div>
<?php endif; ?>

死亡是一个句号;有很多方法可以拦截它,但不是方便的方法。在稍微不同的情况下,return可能会执行您需要的操作,因为它只退出当前函数或文件。

因此我希望不要加载learn col和col last。用鼠标突出显示这些线。点击删除键:


如果不希望显示它们,请使用If-else语句。它将首先查看if部分,如果为true,它将执行代码,如果为false,它将移动到else语句并尝试该操作。

因此我希望不要加载learn col和col last。用鼠标突出显示这些线。点击删除键:


如果不希望显示它们,请使用If-else语句。它将首先查看if部分,如果它为真,它将执行代码,如果它为假,它将移动到else语句并进行尝试。

请不要死!不要放弃希望——总有其他选择


尝试从条件语句中输出标记。

请不要死!不要放弃希望——总有其他选择


尝试从条件语句中输出标记。

oops。。。我从没想过。。。哈哈。。。我从没想过。。。哈哈,至少你可以开个玩笑!祝你的项目好运。至少你可以开个玩笑!祝你的项目好运。