在HTML标记中添加PHP
我可以在HTML在HTML标记中添加PHP,php,html,tags,Php,Html,Tags,我可以在HTMLa标记中使用PHP代码(用于动态内容)吗 我有这样一个代码: <ul> <li> <a href="#" class="offset" title="The sun escaping the horizon"> <img src="img/2.jpg" alt="" class="imagequery"> </a>
a
标记中使用PHP代码(用于动态内容)吗
我有这样一个代码:
<ul>
<li>
<a href="#" class="offset" title="The sun escaping the horizon">
<img src="img/2.jpg" alt="" class="imagequery">
</a>
</li>
</ul>
-
我需要将我的PHP代码作为标题放在标记中。
可能吗?
<?php $title = "My Test Title"; ?>
<ul>
<li>
<a href="#" class="offset" title="<?php echo htmlspecialchars($title); ?>">
<img src="img/2.jpg" alt="" class="imagequery">
</a>
</li>
</ul>
-
//是的,这是可能的
-
你的意思是:为什么不尝试一下,看看会发生什么?标题是动态的,它来自已发表的文章,而不是静态的注释。
//yes it is possible
<ul>
<li>
<?php $title="The sun escaping the horizon";?>
<a href="#" class="offset" title="<?php echo $title;?>">
<img src="img/2.jpg" alt="" class="imagequery">
</a>
</li>
</ul>