如何在另一个php标签和echo中实现php标签和echo?[重复]

问题描述 投票:-1回答:1

基本上我想要的是,当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 session
1个回答
0
投票
 <?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标签之前打开它。

© www.soinside.com 2019 - 2024. All rights reserved.