3

I am working with htmlentites() to replace characters with safe html, namely the PHP because I want to be able to show PHP examples. The problem I am running into is all the tags are replaced (ex: </p>, </br> etc). I know I can write a custom htmentities to only replace the <? tags and other specific xml tags but I was wondering is there something in PHP that already does this?

3
  • It appears that stakoverflow tags actual convert to html....its this an error or do I have to escape them on here to display them Commented Apr 17, 2011 at 15:33
  • Still I don't actually understand what you are talking about. Commented Apr 17, 2011 at 15:34
  • 1
    @Charliepiga - nice edit, far faster than what I did... Commented Apr 17, 2011 at 15:35

1 Answer 1

2

I would use the highlight_string() function in PHP as it will escape the characters and syntax highlight the code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.