为了账号安全,请及时绑定邮箱和手机立即绑定

为什么检测验证码时,浏览器只显示白色正方形边框

$width=200;
$height=50;
$image=imagecreatetruecolor($width,$height);
$white=imagecolorallocate($image,255,255,255);

imagefilledrectangle($image,0,0,$width,$height,$white);
$randColor=imagecolorallocate($image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
$size=mt_rand(20,28);
$angle=mt_rand(-15,15);
$x=50;
$y=30;
$fontFile='fonts/STSONG.TTF';
$text=mt_rand(1000,9999);
imagettftext($image,$size,$angle,$x,$y,$randColor,$fontFile,$text);
header('content-type:image/png');
imagepng($image);
imagedestroy($image);

https://img1.sycdn.imooc.com//5b8f4b9800015e2e18221080.jpg

正在回答

1 回答

童鞋,你这代码没啥问题,应该是 

$fontFile='fonts/STSONG.TTF';

这个字体原因,找不到或者路径不对,导致的。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么检测验证码时,浏览器只显示白色正方形边框

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信