In php, The require and include references to the url and php file encoding conversion functions

Source: Internet
Author: User

This article solves two problems at the same time: require and include Reference url in php and the file encoding conversion function in php. If you need it, you can refer to it.

If the "allow_url_fopen" option is enabled in PHP configuration, you can use url as the include or require parameter.
For more information about allow_url parameters, see the description in php. ini.

Convert the entire page

This method applies to all encoding environments. In this way, the character sets other than the first 128 characters (display characters) are expressed by NCR (Numeric character reference, for example, "Chinese characters" will be converted to "Chinese characters, such encoding can be normally displayed on the page in any encoding environment.

Another problem:
This method applies to all encoding environments. In this way, the character sets other than the first 128 characters (display characters) are expressed by NCR (Numeric character reference, for example, "Chinese characters" will be converted to "Chinese characters, such encoding can be normally displayed on the page in any encoding environment.


Add the following three lines of code to the header of the PHP file:

The Code is as follows: Copy code
Mb_internal_encoding ("gb2312"); // here, gb2312 is the original code of your website.
Mb_http_output ("HTML-ENTITIES ");
Ob_start ('mb _ output_handler ');

To use the mb_convert_encoding function, you must enable the mbstring (multi-byte string) Extension of PHP.

If the php mbstring extension is not enabled, you need to make the following settings:

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.