PHP example development for converting strings to HTML entities

Source: Internet
Author: User
Tags php example
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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.