Home >Backend Development >PHP Problem >Can't php write Chinese characters?

Can't php write Chinese characters?

藏色散人
藏色散人Original
2021-11-10 08:59:221738browse

php can write Chinese characters, but the encoding needs to be set. The setting method is to add the "header("Content-type:text/html; charset=utf-8");" code to the PHP page.

Can't php write Chinese characters?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php Can’t I write Chinese characters?

php can write Chinese characters, but the encoding needs to be set.

Chinese garbled characters

Just this sentence is enough

header("Content-type:text/html; charset=utf-8");

$_GET variable

contains Chinese characters The GET variable, if used in PHP, must be converted into GBK format, otherwise it cannot be displayed using the

';
//必须要转换成GBK
$dirname = iconv('utf-8', 'GBK', $dirname);
echo $dirname.'
'; ?>

browser

Cant php write Chinese characters?

complete Example

Take directory traversal as an example

';
                }
            }
        }
    }
}
read_all($dirname);
?>

Experimental effect

Cant php write Chinese characters?

Recommended study: "PHP Video Tutorial

The above is the detailed content of Can't php write Chinese characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn