Just another WordPress.com site

Show PHP-Source Code

Easy function that shows the PHP-Source Code of the page with syntax high lighting. Might be quite useful just copy it to you page and call it when you want to show you code:

echo '<p> This is the code php file: </ p>';
 $page = highlight_file($_SERVER [ 'SCRIPT_FILENAME'], TRUE);
 $page = str_replace (
 array ( '<code>', '/ code>', '','</ are >','< font color ="'),
 array ( '<pre style="padding:1em;border:2px solid black;overflow:scroll">', '/ pre>', '','</ span >','< span style = "color:' ), $page);
 echo $page;
 echo '<a <p> href="',$_SERVER['PHP_SELF'],'"> Back </ a> </ p>';
 echo '</ body> </ html>';

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Tag Cloud

%d bloggers like this: