如何在另一个php标记和echo中实现php标记和回声



基本上,我想要的是当if语句不返回为空并且它运行第二个echo时,我也想在该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标签。

最新更新