如何在php语音标记之间插入html

时间:2012-09-19 12:50:40

标签: php html

如何在PHP代码的“和”之间插入html。

我想在h hello处插入html代码 - 但它不会让我。

 $this->setError($postName, ucfirst($postName)." hello.");
} else if(strlen($postVal) > intval($max)) {

我想将此代码插入hello。

 <div class="alert alert-success">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
          <strong>Thank You!</strong> We hope to get back to you shortly.
 </div>

2 个答案:

答案 0 :(得分:1)

    $str = '<div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                <strong>Thank You!</strong> We hope to get back to you shortly.
            </div>';

    $this->setError($postName, ucfirst($postName).$str);
} else if(strlen($postVal) > intval($max)) {

答案 1 :(得分:0)

您只需将HTML代码添加到变量中,然后只需将其连接到您想要的位置即可。

这就是:

$html = '<div class="alert alert-success">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Thank You!</strong> We hope to get back to you shortly.
</div>';

    $this->setError($postName, ucfirst($postName).$html);
} else if(strlen($postVal) > intval($max)) {

希望这会有所帮助。 :) (对不起,如果这属于评论,实际上无法在问题中发表评论。)