In web development, how does one process html code entered by users?

Source: Internet
Author: User
To retain the html code entered by the user, the following is the html code: {code ...} sorry, I am not clear enough. What I want to say is: a {code ...} these two rows are the data submitted by the user, perhaps through the editor, or manually input by the user, the server-side program (such... to retain the html code entered by the user, the following is the html code:

a

b

How is this done?

Sorry, I am not clear enough. What I want to say is:

A

b

These two lines are the data submitted by the user, maybe through the editor, or manually input by the user. The data received by the server-side program (such as php) is the above two lines of characters, I would like to ask if the browser displays the two lines of code again and the p and p elements can be parsed by the browser, that is:In the browser, there is a red character a and a green character B. Is there any good way to output them directly to the browser?Because I am worried that the output user's input data will damage the page structure, such:

<

P style = "color: red">

A

Will include an unclosed p tag

Reply content:

To retain the html code entered by the user, the following is the html code:

a

b

How is this done?

Sorry, I am not clear enough. What I want to say is:

A

Set< >Several common symbols in the Code are escaped and converted into HTML Object Storage. PHP provides the htmlspecialchars function.

Yes, you can use the code editor.
For example:
A

B

I entered this in the comment box.

a

b

Can be converted

<p style="color:red">a</p><p style="color:green">b</p>

In general, these code symbols are escaped into html for storage. Generally, relevant functions are available in languages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.