Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of toby lawrence  >  Highlight Code  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example of the usage of the highlighter
Class: Highlight Code
Highlighting PHP code
Author: By
Last change: Explained replace line to cover the protection of vars that contain passwords/logins/etc
Date: 2003-12-14 11:33
Size: 576 bytes
 

Contents

Class file image Download
<?php

include "class.hlight.php";

// code goes here...

// code to tell when to show the source..

$script $_SERVER["SCRIPT_FILENAME"];
$fp fopen($script,"r");
$contents fread($fpfilesize($script));
fclose($fp);

// this code was from one of my own projects, replace $dsn
// to any var that you want to be protected during the
// showing of the source

$contents preg_replace('{(\\$db.*?) = ".*?";}',
'$1="*****";'$contents);

$highlighter = new SyntaxHighlighter_php;
$contents $highlighter->highlight($contents);

echo 
$contents;
?>