我需要回顯很多PHP和HTML。帶PHP的PHP多行字符串
我已經嘗試了很明顯,但它不工作:
<?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代碼? –
除了非轉義引號的明顯問題外,您應該將所有< and >標記轉換爲相應的html代碼< > – transilvlad
大多數人問這個問題會尋找HEREDOC。您可能想要接受該答案。 – Archonic