当前位置: 动力学知识库 > 问答 > 编程问答 >

How can I print out my PHP variables in the html code properly?

问题描述:

This question already has an answer here:

  • Concatenation Operator

    4 answers

网友答案:

Change:

echo '<div class="news-item-detail"><a href="$url" class="news-item-title" target="_blank">$name</a>';

to either:

echo "<div class='news-item-detail'><a href='$url' class='news-item-title' target='_blank'>$name</a>";

or

echo '<div class="news-item-detail"><a href=' . $url . ' class="news-item-title" target="_blank">' . $name . '</a>';

And read the difference about quote styles and strings at http://php.net/manual/en/language.types.string.php

分享给朋友:
您可能感兴趣的文章:
随机阅读: