17
4

10 に答える 10

44
于 2012-10-08T14:55:03.287 に答える
4

PHPファイルにPHPとHTMLを混在させることができます...次のようにしてください...

<?php
$string = htmlentities("Résumé");
?>

<html>
<head></head>
<body>
<p><?= $string ?></p>
</body>
</html>

Résuméそれはあなたが望むように出力するはずです。

短いタグを有効にしていない場合は<?= $string ?><?php echo $string; ?>

于 2012-10-02T22:14:51.907 に答える
1

そこで、<p>Résumé<p> を出力する htmlspecialchars() または htmlentities() を試し、ブラウザは <p>Résumé<p> をレンダリングします。

タグが表示されている場所で動作している場合はRésumé<p></p>段落を変換せずに、文字列のみを変換してください。次に、段落が HTML としてレンダリングされ、文字列が表示されます。

于 2012-10-02T22:11:43.520 に答える
0

これを試して

入力:

<!DOCTYPE html>
<html>
<body>

<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>

<p>Converting &lt; and &gt; into entities are often used to prevent browsers from using it as an HTML element. <br />This can be especially useful to prevent code from running when users have access to display input on your homepage.</p>

</body>
</html>

出力:

This is some <b>bold</b> text.

Converting < and > into entities are often used to prevent browsers from using it as an HTML element. This can be especially useful to prevent code from running when users have access to display input on your homepage.
于 2016-09-07T13:29:56.190 に答える
0

これは私にとってはうまくいきます。HTMLの開始前にこれを試してください。それがあなたにとってもうまくいくことを願っています。

<?php header('Content-Type: text/html; charset=iso-8859-15'); ?>
<!DOCTYPE html>

<html lang="en-US">
<head>

于 2017-08-31T19:09:22.303 に答える