如何解决php imagecreate乱码问题

发布时间:2022-05-25 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了如何解决php imagecreate乱码问题脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

php imagecreate乱码的解决办法:1、通过imagecreate创建画布;2、使用imagecolorallocate设置画布的背景颜色;3、设置“header('content-tyPE:image/gif');”即可。

如何解决php imagecreate乱码问题

本文操作环境:Windows7系统、PHP7.1版、DELL G3

如何解决php imagecreate乱码问题?

PHP创建图像时成为乱码的解决方法(GD)

有问题的代码:

<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html XMlns="http://www.w3.org/1999/xhtml"> 
<head><;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php学习</title>
</head>
<body>
<?php 
$im=imagecreate(200,200);  
//创建一个画布(单位像素pixel)
$white=imagecolorallocate($im,225,66,159); 
//设置画布的背景颜色为粉色 (256RGB)
imagegif($im);  
//输出gif图像
imagedestroy($im); 
?>
 </body>
 </html>

运行结果:

如何解决php imagecreate乱码问题

修改后的代码:

<?php 
$im=imagecreate(200,200); 
//创建一个画布(单位像素pixel)
$white=imagecolorallocate($im,225,66,159); 
//设置画布的背景颜色为粉色 (256RGB)
header('content-type:image/gif');  
//设置gif 
Imageimagegif($im); 
//输出gif图像
imagedestroy($im); 
?>

运行结果:

如何解决php imagecreate乱码问题

推荐学习:《PHP视频教程》

以上就是如何解决php imagecreate乱码问题的详细内容,更多请关注脚本宝典其它相关文章

脚本宝典总结

以上是脚本宝典为你收集整理的如何解决php imagecreate乱码问题全部内容,希望文章能够帮你解决如何解决php imagecreate乱码问题所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:php