Jump to content

Recommended Posts

Basically, I'm trying to take a string from the db and do two things.

[*]Prevent html from being processed as html (htmlspecialchars() i think)

[*]Recognize PHP code and highlight it.

 

This is a reply system much like what I'm typing right now. For example 2, I want to be able to do this

<?php
echo "hello";
?>

 

I've researched a little and found a function called highlight_php(). The problem I run into now is that I only want to highlight php when it is needed. I am stuck as to where to go next. My thoughts would be 2 regex functions, however I don't know which one to call first. Any suggestions? Everything is appreciated

Link to comment
https://forums.phpfreaks.com/topic/251412-highlighting-code-and-others/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.