note 109385 added to function.highlight-file
| From: | programacion at mundosica dot com | Date: | Thu, 12 Jul 2012 23:14:40 +0000 |
| Subject: | note 109385 added to function.highlight-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189113@lists.php.net to get a copy of this message | ||
#!/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>",
" "
),
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
----
Server IP: 69.147.83.197
Probable Submitter: 189.188.158.107
----
Manual Page -- http://www.php.net/manual/en/function.highlight-file.php
Edit -- https://master.php.net/note/edit/109385
Del: integrated -- https://master.php.net/note/delete/109385/integrated
Del: useless -- https://master.php.net/note/delete/109385/useless
Del: bad code -- https://master.php.net/note/delete/109385/bad+code
Del: spam -- https://master.php.net/note/delete/109385/spam
Del: non-english -- https://master.php.net/note/delete/109385/non-english
Del: in docs -- https://master.php.net/note/delete/109385/in+docs
Del: other reasons-- https://master.php.net/note/delete/109385
Reject -- https://master.php.net/note/reject/109385
Search -- https://master.php.net/manage/user-notes.php