如何在另一个php标记和echo中实现php标记和echo?
基本上,我想要的是当if语句不返回为空并且它运行第二个echo时,我还想要在该echo中回显$\u会话变量如何在另一个php标记和echo中实现php标记和echo?,php,session,Php,Session,基本上,我想要的是当if语句不返回为空并且它运行第二个echo时,我还想要在该echo中回显$\u会话变量 <?php $gallerystatus = $_SESSION['u_gallerypicture']; if(empty($gallerystatus)){ echo'<p> No posts uploaded yet... To add a photo click the New Post button.</p>
<?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标记之前,您不需要打开它。所有会话数组都有值吗?您是否用
}
关闭了else
?我看不到。使用“.”来连接字符串。提示,如果你将要回显大量的HTML,只是从php中分离出来,代码看起来更干净,编辑器可以识别语法突出显示/格式。你的代码不工作只是更新了,我没有以同样的方式看到第二个php标记,请检查答案。请阅读官方文件
<?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>';?>