Output code source, then run it.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Output code source, then run it.

Post by Skara »

Ok, say I have this in a file:

Code: Select all

<?php
echo 'blah';
?>
I'd like the out put of the file to be...

Code: Select all

<?php
echo 'blah';
?>
---------
blah
In other words, show the code first (or second, whatever), then run it.


The only way I can think to do this is to add a .htaccess redirection to another file that would read the given file as text, etc etc.

There another way to do this easily?

I plan on using this for teaching purposes, if you're curious.
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

You can do highlight_file() then require().
Post Reply