World of Warcraft cannot read the required files PHP read file garbled problem

Source: Internet
Author: User
Tags php read file
The solution on the net said after crawling with Iconv () transcoding. Look after I feel that something is wrong: one is not necessarily compiled Iconv library, the bigger problem is that the encoding is the same as the time of the stream conversion (if the use of iconv actually PHP two times code: Flow, UTF-8, GB2312): This is not the white busy it?
Carefully read the PHP document (do not know how people write code, in fact the document is very clear AH), above about fopen () and file_get_contents () mentioned "default is UTF-8, but users can use Stream_default_ Encoding () or user-defined context attribute change encoding "(If Unicode semantics is enabled, the default encoding of the read data is UTF-8. You can specify a different encoding by creating a custom context or by changing the default using Stream_default_encoding ().)。 So with stream_default_encoding (' gb2312′); test: But faint, this function does not exist?! It seems that PHP 6 is not supported. But despair, there are "user-defined context properties" that you can use.
After a closer look at the document, the problem was solved:

Copy the Code code as follows:


Sets the encoding format of the stream, which is the file stream, which, if it is network access, changes to HTTP
$opts = Array (' file ' = = Array (' encoding ' = ' gb2312 '));
$ctxt = Stream_context_create ($opts);
file_get_contents (filename, file_text, $ctxt);

The above describes the world of Warcraft can not read the required files PHP read file garbled problem, including the World of Warcraft can not read the required files in terms of content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.