【发布时间】:2012-09-14 03:07:51
【问题描述】:
我需要回显很多 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 代码吗?
-
除了未转义引号的明显问题之外,您还应该将所有 标记转换为其对应的 html 代码 < >
-
大多数问这个问题的人都会寻找HEREDOC。你可能想接受这个答案。