PHP多行字符串与PHP

标签 php html multiline

我需要回显很多 PHP 和 HTML。

我已经尝试了显而易见的方法,但它不起作用:

<?php echo '
<?php if ( has_post_thumbnail() ) {   ?>
      <div class="gridly-image"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail('summary-image', array('class' => 'overlay', 'title'=> the_title('Read Article ',' now',false) ));?></a>
      </div>
      <?php }  ?>

      <div class="date">
      <span class="day">
        <?php the_time('d') ?></span>
      <div class="holder">
        <span class="month">
          <?php the_time('M') ?></span>
        <span class="year">
          <?php the_time('Y') ?></span>
      </div>
    </div>
    <?php }  ?>';
?>

我该怎么做?

最佳答案

你不需要输出php标签:

<?php 
    if ( has_post_thumbnail() ) 
    {
        echo '<div class="gridly-image"><a href="'. the_permalink() .'">'. the_post_thumbnail('summary-image', array('class' => 'overlay', 'title'=> the_title('Read Article ',' now',false) )) .'</a></div>';
    }

    echo '<div class="date">
              <span class="day">'. the_time('d') .'</span>
              <div class="holder">
                <span class="month">'. the_time('M') .'</span>
                <span class="year">'. the_time('Y') .'</span>
              </div>
          </div>';
?>

关于PHP多行字符串与PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12534836/

相关文章:

jquery - 更改导航菜单类并在滚动或单击时显示子树菜单

html - 标题中的中心复选框

html - 重写 CSS 子类

elasticsearch - 为什么 Logstash 不会基于 grok'd 字段合并行?

javascript - 隐藏css3多行省略号在没有用处时阅读更多链接

php - 计算smarty 3模板prestashop中两个日期之间的差异

php - 更新行直到总和匹配?

php - 如何使用 php 选择 mysqli 进行标签搜索?

php - 如何使用 {'property-names-like-this' 声明动态 PHP 类 }

regex - 行长和多行输入的正则表达式