How to convert htmlentities to UTF-8

Source: Internet
Author: User
Problem of converting UTF-8 from htmlentities to Chinese $ str = "Chinese"; echo & nbsp; json_encode ($ str); displayed as: [null] & nbsp; so I plan to use htmlentities & nbsp; please refer to the following link for details: $ str = htmlentities ($ str, UTF-8); echo & nbsp; j: converting htmlentities to UTF-8 in Chinese
$ Str = "Chinese ";
Echo json_encode ($ str );

Shown:
[Null]

So I want to use htmlentities to turn it over:
$ Str = htmlentities ($ str, UTF-8 );
Echo json_encode ($ str );

The result is a very depressing problem.
Notice: Use of undefined constant utf-assumed 'utf' in F: \ work \ test. php on line 24

["\ Ufffd \ u052a \ ufffd \ Alibaba \ ufffd \ uccef \ Alibaba \ ufffd \ u3d22 \ ufffd"


Line 24: $ str = htmlentities ($ str, UTF-8 );

The result is successfully converted, but I don't know why the error is reported!
------ Solution --------------------
The parameters must be enclosed in quotation marks. why not use iconv?

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.