Skip to content

Instantly share code, notes, and snippets.

@JackZielke
Created February 25, 2022 21:33
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 JackZielke/a32821d76e529a39e72413f90c4b7efb to your computer and use it in GitHub Desktop.
Save JackZielke/a32821d76e529a39e72413f90c4b7efb to your computer and use it in GitHub Desktop.
View highlighted PHP source code oneliner
<?php
if (isset($_GET['viewsource'])) { die(highlight_file(__FILE__, 1)); }
// Put the rest of your PHP code here
// Somewhere in the code add the following HTML line (or something similar to it).
<a rel="nofollow" href="?viewsource">View Source</a>
@JackZielke
Copy link
Author

This creates the same output you would get from a .phps file. It uses the built-in syntax highlighter.

@JackZielke
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment