Home  >  Article  >  Backend Development  >  How to connect php to html

How to connect php to html

(*-*)浩
(*-*)浩Original
2019-09-30 10:17:175663browse

PHP and HTML have many interactions: PHP can generate HTML, and HTML can pass information to PHP.

How to connect php to html

HTML parsing. To specify an arbitrary string, you must put it in double quotes and use htmlspecialchars() to process the entire value. (Recommended learning: PHP video tutorial)

URL: URL consists of several parts. If you want your data to be interpreted as one of these, you must encode it with urlencode().

Hidden HTML form unit

\n";
?>

Note:

It is wrong to use urlencode() to process $data. Because it is the browser's responsibility to urlencode() the data. All popular browsers handle it correctly. Note that this happens regardless of the method (such as GET or POST). You'll only notice this when using GET requests, since POST requests are usually hidden.

Data waiting for user editing

\n";
    echo htmlspecialchars($data)."\n";
    echo "";
?>

Note:

The data will be displayed in the browser as expected because Browsers interpret HTML escape symbols. When submitted, whether it is the GET or POST method, the data will be urlencoded by the browser and transmitted directly by PHP urldecode. So in the end you don't need to handle any urlencoding/urldecoding yourself, it's all handled automatically.

Example in URL

\n";
?>

#Note:

In fact, this is making up an HTML GET request, so you need to manually urlencode( ).

The above is the detailed content of How to connect php to html. For more information, please follow other related articles on the PHP Chinese website!

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