English 中文(简体)
可以在 DIV 标记中插入 PHP 代码, 而不是文本标题属性的文本 [已关闭]
原标题:Is possible put PHP code instead of text in Title attribute in the DIV tag [closed]
最佳回答

<div id="example" title="<?php echo the_excerpt(); ?>"> some text </div>

或:

<div id="example" title="<?= the_excerpt() ?>"> some text </div>

后者是一个速记,自动回响PHP区块中的一切内容,而前者可以包含任何代码,包括回响某些东西的代码(打印到区块所在的位置)。

basic syntrax 。

但请注意, 以避开您输出到 HTML 的任何内容, 以确保它是有效的属性值( 除非 < code> the_ except () 已经返回一个逃出字符串 ):

<div id="example" title="<?= htmlspecialchars(the_excerpt()) ?>"> some text </div>
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签