Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created November 2, 2020 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/b0bf00665ecfea096752f664012adfad to your computer and use it in GitHub Desktop.
Save phpfiddle/b0bf00665ecfea096752f664012adfad to your computer and use it in GitHub Desktop.
[ Posted by Amar Beslija ] How to show PHP code inside HTML page for showcases or examples. https://lab387.com
<?php
/* If we want to show some PHP code inside HTML page for showcase, example, etc., here is the way to do it */
// Code we want to show inside HTML page
$code = '
<?php
echo "Test code to be output with everything else";
?>';
// Output full HTML Code, changing "<" and ">" to HTML Entities
echo "<pre>" . htmlspecialchars($code) . "</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment