HTML entity symbols are used to implement reserved characters or to express some characters commonly used that cannot be entered by the keyboard. In most browsers, the default character set is Iso-8859-1. HTML entity Symbols We often use it in web design, so how do we use PHP to convert non-ASCII strings into HTML entities, strings to encode, and return HTML entity references.
Step One: Download our class library for PHP to convert strings to HTML entities in this lesson: http://www.php.cn/xiazai/leiku/608
Step two: After the download is complete, unzip the file to a local directory and create a new PHP file!
Step Three: Call the class and instantiate in the new PHP file:
<?phpinclude_once "stringhtml.php"; Introduction of Class Library $obj = new HtmlEncode; Instantiate the class//definition string and encode $str = "Chinese net"; $srcEncoding = "Utf-8"; Echo $obj->encode ($str, $srcEncoding);//return HTML entity reference
The final run results are as follows: