开发者社区 问答 正文

用php生成一张图片,但是显示不出来?

<?php
session_start();
for($i=0;$i $_nmsg.= dechex(mt_rand(0,15));
}
$_SESSION['code']=$_nmsg;
$_width=75;
$_height=25;
$_img=imagecreatetruecolor($_width,$_height);
$_white=imagecolorallocate($_img,255,255,255);
imagefill($_img,0,0,$_white);
header('Content-Type:image/png');
imagepng($_img);
imagedestroy($_img);
?>

screenshot

展开
收起
小旋风柴进 2016-03-06 16:26:19 3593 分享 版权
1 条回答
写回答
取消 提交回答
  • 这个php文件要保证编码为utf-8,其他不行的。然后直接访问这文件或者放在html的img标签里

    2019-07-17 18:54:49
    赞同 展开评论
问答分类:
PHP
问答标签:
问答地址: