Home >Backend Development >PHP Tutorial > php绘制中文的乱码有关问题

php绘制中文的乱码有关问题

WBOY
WBOYOriginal
2016-06-13 13:17:43781browse

php绘制中文的乱码问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php //    1.
        $img=imagecreatetruecolor(400,400);
        
        $white=imagecolorallocate($img, 255, 255, 255);
        $gray=imagecolorallocate($img, 0xC0, 0xC0, 0xC0);
        $darkgray=imagecolorallocate($img, 0x90, 0x90, 0x90);
        $navy=imagecolorallocate($img, 0, 0, 0x80);
        $darknavy=imagecolorallocate($img, 0, 0, 0x50);
        $red=    imagecolorallocate($img, 0xFF, 0, 0);
        $darkred=imagecolorallocate($img, 0x90, 0, 0);
        
        
//     2.
        imagefill($img,0,0,$red);

        
        imagettftext($img,20,-60,60,150,$darknavy,"simhei.ttf","一二三");

        
        
        
        
//     3.
        header("Content-Type:image/gif");
        imagegif($img);
        
//     4.
        imagedestroy($img);
        





  "一二三"无法显示,只有几个方框,怎样解决乱码问题?先谢谢!!!

------解决方案--------------------
imagettftext($img,20,-60,60,150,$darknavy,"simhei.ttf", iconv('gbk', 'utf-8', "一二三") );
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