基本上我想要的是,当if语句没有返回为空,并且运行第2个echo时,我还想在该echo中回传$_SESSION变量。
<?php
$gallerystatus = $_SESSION['u_gallerypicture'];
if(empty($gallerystatus)){
echo'<p> No posts uploaded yet... To add a photo click the New Post button.</p>';
}
else{
echo'
<!-- Main container -->
<div id="content-container">
<div class="gallery group">
<div class="grid">
<a href="#">
<img height="216.66" src=" <?php echo "../image-gallery-upload/images/" . $_SESSION["u_gallerypicture"]; ?> ">
<span><?php echo $_SESSION["u_caption"]; ?></span>
</a>
</div>';}?>
<?php
$gallerystatus = $_SESSION['u_gallerypicture'];
if(empty($gallerystatus)){
echo'<p> No posts uploaded yet... To add a photo click the New Post button.</p>';
}
else{
echo'
<!-- Main container -->
<div id="content-container">
<div class="gallery group">
<div class="grid">
<a href="#">
<img height="216.66" src="../image-gallery-upload/images/"' . $_SESSION["u_gallerypicture"] . '">
<span> ' . $_SESSION["u_caption"] . '</span>
</a>
</div>';?>
试着把它连起来就可以了。你永远不需要在关闭PHP标签之前打开它。