如何解决php gd中文乱码问题
本文操作环境:Windows7系统、PHP7.1版、DELL G3电脑
如何解决php gd中文乱码问题?
今天仔细研究了下GD的一些相关技术,顺手也研究下GD中文乱码的问题。
使用GD库输出中文字符串,调用imagestring是没有用的。需要使用imagettftext()函数。imagettftext函数的具体使用就参考手册啦。
下面给个使用实例:
$pic=imagecreate(250,30); $black=imagecolorallocate($pic,0,0,0); $white=imagecolorallocate($pic,255,255,255); $font="C://WINDOWS//Fonts//simhei.ttf"; //这里的路进需要注意下,必须是字符的路径 $str ='php'.iconv('gb2312','utf-8','面对对象')." www.phpobject.net"; imagettftext($pic,10,0,10,20,$white,$font,$str);
版权声明:
作者:后浪云
链接:https://www.idc.net/help/8855/
文章版权归作者所有,未经允许请勿转载。
THE END