To preserve the HTML code entered by the user, here is the HTML code:
ab
How it's done.
Sorry, I don't speak clearly enough, I want to say:
A
b
These two lines are user-submitted data, perhaps through the editor, perhaps the user manually input, server-side programs (such as PHP) received the data is the above two lines of characters, I would like to ask is if the browser again display the two lines of code and the DIV and P elements can be parsed by the browser, namely: In the browser is a red character A and a green B, in addition to directly output them to the browser is there any good way? because I'm worried about the output of the user's input data will break the page structure, such as:
<
Div style= "color:red" >
A
Will bring in an unclosed div tag.
Reply content:
To preserve the HTML code entered by the user, here is the HTML code:
ab
How it's done.
Sorry, I don't speak clearly enough, I want to say:
A
<
>
escape Several common symbols of code and turn them into HTML entity storage. PHP words have htmlspecialchars functions.
Well, you can use the Code Editor.
Like what:
A
B
That's what I got in the comment box.
ab
can be converted into
<div style="color:red">a</div><p style="color:green">b</p>
In general, these code symbols are escaped into HTML to store. The general language has the correlation function to implement it.