I made a tiny tool for myself today, to make it easier to display both HTML and PHP code in this site (if you just input it as is it will get filtered, as it would be unsafe otherwise)

It’s a small webform that lives as a shortcut in my browser bar:

Which calls itself when submitted, and if there is some input it will encode it by calling the PHP function htmlentities twice (otherwise it would just show the right output, but not what is needed to get that output). The result is shown above the form. Maybe I’ll add a step to put it on the clipboard instead. That would save another step. Currently I run it on an internet accessible webserver, I will likely move it to the webserver I run locally on my laptop Moved it my laptop’s local webserver (making it both safer, and independent from having internet access).

<?php echo "<pre>".htmlentities(htmlentities($_POST["input_tekst"], ENT_QUOTES))."</pre>"; ?>

This makes it possible to document code changes much better in my site. Such as my recent language adaptations.

The code snippet above has of course been made with this form.

2 reactions on “Showing html and php code on this site

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.