Echo语句在输出中呈现html代码

时间:2014-10-06 11:40:15

标签: php

这是一个基本问题,我觉得很尴尬。每当我回显html标签,而不是渲染标签时,它只会显示在echo输出中。我试过单引号和双引号,但仍然没有运气。我在这做错了什么?感谢

<a style="margin-left: 12px;" href="javascript:void(0)" class="tooltip" title="<?php echo "Please select your boxes from the list. You can select a max of 20 boxes per submission.<br />You can select multiple boxes by holding the left ctrl on your keyboard and making your selection"; ?>">Help</a> 

ff渲染输出:

title="Please select your boxes from the list. You can select a max of 20 boxes per submission.<br />You can select multiple boxes by holding the left ctrl on your keyboard and making your selection" 

2 个答案:

答案 0 :(得分:1)

HTML代码不能放在标题标记内,因为浏览器不会将标题呈现为纯文本字符串以外的任何内容。

答案 1 :(得分:1)

使用此代替您的<a/>代码:

<a style="margin-left: 12px;" href="javascript:void(0)" class="tooltip" title="<?php echo 'Please select your boxes from the list. You can select a max of 20 boxes per submission.<br />You can select multiple boxes by holding the left ctrl on your keyboard and making your selection';?>">Help</a> 

或者:

<?php 
$titleText =  'Please select your boxes from the list. You can select a max of 20 boxes per submission.<br />You can select multiple boxes by holding the left ctrl on your keyboard and making your selection';
?>

<a style="margin-left: 12px;" href="javascript:void(0)" class="tooltip" title="<?=$titleText;?>">Help</a>