note 109385 deleted from function.highlight-file by danbrown

From: Date: Mon, 16 Jul 2012 15:34:54 +0000
Subject: note 109385 deleted from function.highlight-file by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189185@lists.php.net to get a copy of this message
Note Submitter: programacion at mundosica dot com ---- #!/usr/bin/php #File: customHighlightCode.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Nice highlightCode</title> <?php $fileName = $argv[0]; if(isset($argv[1]) && file_exists($argv[1])){ $fileName = $argv[1]; } /** * Conviert you php code to a nice HTML highlightCode :¬) * * @param string $fileName * @return highlightCode */ function customHighlightCode($fileName) { return str_replace( array( "style=\"color: #000000\"", "style=\"color: #0000BB\"", "style=\"color: #DD0000\"", "style=\"color: #FF8000\"", "style=\"color: #007700\"", "<br />", "code>", "&nbsp;" ), array( "class=\"html\"", "class=\"php-default\"", "class=\"php-str\"", "class=\"php-comment\"", "class=\"php-word\"", "\n", "pre>", " " ), highlight_file("$fileName", true) ); }//end function ?> <head> <title><?php echo $fileName; ?></title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <style type="text/css" media="all"> pre{ background: #1A1A1A; color: #FFF; font-size: 15px; text-shadow:0 0 3px #000,-1px -1px 0 #000,1px 1px 0 #000; } .html{color: #6253E5;text-shadow:none} .php-comment{color: #444;} .php-default{color: #FFF;} .php-word{color: #00CE00;} .php-str{color: #E05D09;} </style> </head> <body> <h2><?php echo $fileName; ?></h2> <?php echo customHighlightCode($fileName); ?> </body> </html> #Generating the out.html php customHighlightCode.php otherFile.php > out.html #view the results firefox out.html

« previous php.notes (#189185) next »