Home  >  Article  >  Backend Development  >  Server.HTMLEncode allows code to be displayed as source code on the page_PHP tutorial

Server.HTMLEncode allows code to be displayed as source code on the page_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:021088browse

Today, because the program needs to display the html source code written to the database in the form of html source encoding on the page, rather than being interpreted by the browser. . After searching for a long time and not knowing how to do it, I looked at a program that has the function of modifying templates. . I found a method that turned out to be an asp ^^ and wrote it down

Server.HTMLEncode

HTMLEncode

1. The HTMLEncode method applies HTML encoding to the specified string.

Syntax
Server.HTMLEncode( string )

Parameters

string

Specify the string to encode.
Example

Script

Copy code The code is as follows:

<%= Server.HTMLEncode("The paragraph tag:

" ) %>


output

The paragraph tag:

NOTE The above output will be displayed by a web browser as

The paragraph tag:


If you look at the source file or open a web page in text mode, you can see the encoded HTML

2. Analysis of related examples:

rs("content")=Server.Htmlencode(Request("content")) :

rs("content") means that rs is a recordset object and content is a field in the database table; the recordset object can operate every record in the database table and every field in it.

The function of Server.Htmlencode: is to convert certain codes into html format.

Request("content") means: there is a value of an element named content in the previous page returned; it may be a text box in the form, or it may be a querystring type thing
But Judging from the name and habits, it is a multi-line text box of a form, because it is used to place content.
The overall meaning is that it puts the value in the text box passed from the previous submission page in the database Now in the content field of the opened record.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621694.htmlTechArticleToday, because the program needs to display the html source code written to the database in the form of html source encoding on the page, rather than being interpreted by the browser. . After searching for a long time and not knowing what to do...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn