note 42363 deleted from function.highlight-file by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 13:56:01 +0000 |
| Subject: | note 42363 deleted from function.highlight-file by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77371@lists.php.net to get a copy of this message | ||
Note Submitter: dave_arter at hotmail dot com
----
You may have noticed that this function doesn't return valid XHTML, due to its use of the
<font> tags. Here's my solution to this problem:
<?php
function highlight_file_xhtml($file, $return=FALSE){
$syntax = show_source($file, TRUE);
$syntax = str_replace("<font color=\"", "<span style=\"color:
", $syntax);
$syntax = str_replace("</font>", "</span>", $syntax);
if ($return){
return $syntax;
} else {
print $syntax;
}
}
?>
Syntax of this function is exactly the same as PHP's highlight_file().