note 36158 added to function.highlight-file
| From: | Yakir at rn2 dot php dot net | Date: | Mon, 29 Sep 2003 05:20:50 +0000 |
| Subject: | note 36158 added to function.highlight-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57250@lists.php.net to get a copy of this message | ||
hii, my name is Yakir Sitbon. This is class of Style to Code PHP.
<?
class my_highlight_string
{
function my_highlight_string ($html='#0000ff',
$default='#0000BB',
$keyword='#000080',
$string='#b60033',
$comment='#008000',
$tag_open_close='#ffffcc'
) //constructor
{
echo "<style>\n";
echo ".source span.html { color: $html; }\n";
echo ".source span.default { color: $default; }\n";
echo ".source span.keyword { color: $keyword; FONT-WEIGHT: bold;}\n";
echo ".source span.string { color: $string; }\n";
echo ".source span.comment { color: $comment; font-style: italic; }\n";
echo ".source span.tag_open_close { color: $default; BACKGROUND-COLOR: $tag_open_close;
}\n";
echo "</style>\n";
}
function PrintCode ($code)
{
echo '<pre class="source">';
$source = highlight_string($code, TRUE);
// search style.
$search[0] = '<font
color="'.ini_get('highlight.html').'">';
$search[1] = '<font
color="'.ini_get('highlight.default').'">';
$search[2] = '<font
color="'.ini_get('highlight.keyword').'">';
$search[3] = '<font
color="'.ini_get('highlight.string').'">';
$search[4] = '<font
color="'.ini_get('highlight.comment').'">';
$search[5] = '</font>';
$search[6] = '<br />';
$search[7] = '\r';
$search[8] = ' ';
$search[9] = '<?';
$search[10] = '?>';
// replace style.
$replace[0] = '<span class="html">';
$replace[1] = '<span class="default">';
$replace[2] = '<span class="keyword">';
$replace[3] = '<span class="string">';
$replace[4] = '<span class="comment">';
$replace[5] = '</span>';
$replace[6] = "\n";
$replace[7] = '';
$replace[8] = ' ';
$replace[9] = '<span class="tag_open_close"><?</span>';
$replace[10] = '<span class="tag_open_close">?></span>';
echo str_replace($search, $replace, $source);
echo '</pre>';
}
}
?>
Thanks you, Yakir Sitbon. :)
----
Manual Page -- http://www.php.net/manual/en/function.highlight-file.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36158
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36158&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36158&report=yes