Home>Article>Backend Development> Example development of php converting strings into html entities

Example development of php converting strings into html entities

黄舟
黄舟 Original
2017-08-15 13:47:04 3200browse

htmlEntity symbols are used to implement reserved characters or express some common characters that cannot be input by the keyboard. The default character set in most browsers is ISO-8859-1. We often use html entity symbols in web design, so how do we use php to convert non-ASCII strings into HTML entities, encode the strings, and return HTML entity references.

Step one: Download the PHP class library we need for this lesson to convert strings into HTML entities://m.sbmmt.com/xiazai/leiku/608

Step 2: After the download is complete, unzip the file to the local directory and create a new php file!

The third step: Call the class and instantiate it in the new php file:

encode($str,$srcEncoding);//返回HTML实体引用

The final running result is as shown below:

Example development of php converting strings into html entities

The above is the detailed content of Example development of php converting strings into html entities. 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