Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
未解析の PHP コードを HTML に表示したいと考えています。たとえば、これを HTML ドキュメントでレンダリングしたいとします。
これはPHPでテキストを印刷する方法です <?php print "Hello!"; ?>
これはPHPでテキストを印刷する方法です
<?php print "Hello!"; ?>
を使用してコードを文字列として出力するとhtmlspecialchars()、サーバーまたはブラウザによってコードが解析されなくなります。
htmlspecialchars()
echo htmlspecialchars('<?php print "Hello!"; ?>')