-1

PHP コードの " と " の間に HTML を挿入するにはどうすればよいですか。

html コードをそこに挿入したいのですが、挿入helloできません。

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

こんにちはと言う場所にこのコードを挿入したいと思います。

 <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>
4

2 に答える 2

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)) {
于 2012-09-19T12:52:08.410 に答える
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)) {

お役に立てれば。:) (これがコメントに属している場合は申し訳ありませんが、実際に質問にコメントすることはできません。)

于 2012-09-19T12:53:18.050 に答える