Introduction to the method of PHP outputting HTML code as it is on the page

青灯夜游
Release: 2023-04-08 13:56:02
forward
3985 people have browsed it

This article will introduce to you how PHP outputs HTML code as it is on the page. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Introduction to the method of PHP outputting HTML code as it is on the page

#The conversion between strings and HTML is mainly done using the htmlentities() function.

Introduction to the method of PHP outputting HTML code as it is on the page

php中文网"; echo $str; echo "
"; echo htmlentities($str,ENT_QUOTES,"UTF-8"); ?>
Copy after login

The running result is:

Introduction to the method of PHP outputting HTML code as it is on the page

Tips: When applying this function to convert a string into an HTML string During the process, set the character set of the parameter charset to utf-8 to avoid garbled characters when outputting Chinese characters.

htmlentities() function converts characters into HTML entities.

Tip: To convert HTML entities back to characters, use the html_entity_decode() function.

Tip: Please use the get_html_translation_table() function to return the translation table used by htmlentities().

Recommended:PHP video tutorial

The above is the detailed content of Introduction to the method of PHP outputting HTML code as it is on the page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:csdn.net
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!