ok i know i started my own syntax highlighting project before. but i wanted to try and use the built in php syntax highlighter
for experimental purposes.
any ideas why isnt this working.
/** Show Post */
function Show_Post($Posts_To_Show, $File_Path)
{
$Show_Posts = file($File_Path);
for($k = 0; $k<$Posts_To_Show; $k++)
{
echo preg_replace('/<div class="codebox">(.*?)<\/div>/i', '<div class="codebox">'.highlight_string('\\1', true).'</div>', $Show_Posts[$k]);
}
} /** End Of Show Post Function */
//
//
//
its an attempt to use php built in highlighter.
but the resulting source code come back like this when displayed..
<div class="codebox"><code><span style="color: #000000">
/** Show Post */
function Show_Post($Posts_To_Show, $File_Path)
{
$Show_Posts = file($File_Path);
for($k = 0; $k<$Posts_To_Show; $k++)
{
echo preg_replace('/<div class="codebox">(.*?)<\/div>/i', '<div class="codebox">'.highlight_string('\\1', true).'</div>', $Show_Posts[$k]);
}
} /** End Of Show Post Function */
</span></code></div>
//
//
//
//
basically just turning all text black.
so its finding the string of code. adding the code tag and only 1 span style color.
i was wondering if it would possibly have something to do with the htmlentities i set on the string before adding it to database.
then use this function to pull the string from the database then try to highlight it.
as i need htmlentities() to be used so i dont have raw php code going into the database.
or else if would make the text outside the codeboxes to become vunerable to attacks.
ive tried many things. including trying to html_entity_decode() just the text inside the codebox but it still returns black text rather than colored.
but then that just sent back <?php \1 ?> rather than the text. although this time it was colored.
its just frustrating. this is suppose to be the easy route. rather than making your own.
but ive had more issues trying to correct this than i had making my own upto the point where i had
that commenting issue lol.
it sounds like you have another code that you have not showed us interfering with the code....
im guessing you could do a string replacement for the code and replace // with ///