note 94835 added to function.highlight-file
| From: | HDF at osu1 dot php dot net | Date: | Fri, 27 Nov 2009 14:02:24 +0000 |
| Subject: | note 94835 added to function.highlight-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163339@lists.php.net to get a copy of this message | ||
This is a simple little code I use, to Syntax Highlight my own file with line numbers:
<style type="text/css">
.num {
color: gray;
text-align: right;
margin-right: 6pt;
padding-right: 6pt;
border-right: 1px solid gray;
width: 20px;
display: inline-block;
}
</style>
<?PHP
function highlight($file)
{
$code = explode("<br />", highlight_file($file, 1));
foreach ($code as $key => &$value) {
$add = "<span class=\"num\">" . ($key + 1) .
"</span>";
if ($key == 0) {
$value = substr($value, 0, 36) . $add . substr($value, 36);
} else {
$value = $add . $value;
}
}
echo implode("<br />", $code);
}
highlight(substr(strrchr($_SERVER["PHP_SELF"], '/'), 1));
?>
----
Server IP: 69.147.83.197
Probable Submitter: 89.134.173.6
----
Manual Page -- http://www.php.net/manual/en/function.highlight-file.php
Edit -- https://master.php.net/note/edit/94835
Del: integrated -- https://master.php.net/note/delete/94835/integrated
Del: useless -- https://master.php.net/note/delete/94835/useless
Del: bad code -- https://master.php.net/note/delete/94835/bad+code
Del: spam -- https://master.php.net/note/delete/94835/spam
Del: non-english -- https://master.php.net/note/delete/94835/non-english
Del: in docs -- https://master.php.net/note/delete/94835/in+docs
Del: other reasons-- https://master.php.net/note/delete/94835
Reject -- https://master.php.net/note/reject/94835
Search -- https://master.php.net/manage/user-notes.php