ubuntu的PHP服务器,验证码图片不显示字符,怎么回事
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ubuntu的PHP服务器,验证码图片不显示字符,怎么回事,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1691字,纯文字阅读大概需要3分钟。
内容图文
ubuntu 的PHP服务器,验证码图片不显示字符,怎么回事?有图片生成,就是没有字符显示.是字符集错误了吗?哪里设置?
回复讨论(解决方案)
代码贴出来看一下
把直接打开生成的图片看一下,看看是否正常!
代码贴出来看一下
=0 ) { imagesetpixel ($distortion_im, (int)($i+10+sin($j/$im_y*2*M_PI-M_PI*0.1)*4) , $j , $rgb); } } } //加入干扰象素; $count = 160;//干扰像素的数量 for($i=0; $i<$count; $i++){ $randcolor = ImageColorallocate($distortion_im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); imagesetpixel($distortion_im, mt_rand()%$im_x , mt_rand()%$im_y , $randcolor); } $rand = mt_rand(5,30); $rand1 = mt_rand(15,25); $rand2 = mt_rand(5,10); for ($yy=$rand; $yy<=+$rand+2; $yy++){ for ($px=-80;$px<=80;$px=$px+0.1) { $x=$px/$rand1; if ($x!=0) { $y=sin($x); } $py=$y*$rand2; imagesetpixel($distortion_im, $px+80, $py+$yy, $text_c); } } //设置文件头; Header("Content-type: image/JPEG"); //以PNG格式将图像输出到浏览器或文件; ImagePNG($distortion_im); //销毁一图像,释放与image关联的内存; ImageDestroy($distortion_im); ImageDestroy($im);}function make_rand($length="32"){//验证码文字生成函数 $str="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $result=""; for($i=0;$i<$length;$i++){ $num[$i]=rand(0,25); $result.=$str[$num[$i]]; } return $result;}//输出调用$checkcode = make_rand(4);session_start();//将随机数存入session中$_SESSION['helloweba_gg']=strtolower($checkcode);getAuthImage($checkcode);?>
windows的服务器可以. 就是ubuntu 不行
把直接打开生成的图片看一下,看看是否正常!
windows的服务器可以. 就是ubuntu 不行
代码贴出来看一下
=0 ) { imagesetpixel ($distortion_im, (int)($i+10+sin($j/$im_y*2*M_PI-M_PI*0.1)*4) , $j , $rgb); } } } //加入干扰象素; $count = 160;//干扰像素的数量 for($i=0; $i<$count; $i++){ $randcolor = ImageColorallocate($distortion_im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); imagesetpixel($distortion_im, mt_rand()%$im_x , mt_rand()%$im_y , $randcolor); } $rand = mt_rand(5,30); $rand1 = mt_rand(15,25); $rand2 = mt_rand(5,10); for ($yy=$rand; $yy<=+$rand+2; $yy++){ for ($px=-80;$px<=80;$px=$px+0.1) { $x=$px/$rand1; if ($x!=0) { $y=sin($x); } $py=$y*$rand2; imagesetpixel($distortion_im, $px+80, $py+$yy, $text_c); } } //设置文件头; Header("Content-type: image/JPEG"); //以PNG格式将图像输出到浏览器或文件; ImagePNG($distortion_im); //销毁一图像,释放与image关联的内存; ImageDestroy($distortion_im); ImageDestroy($im);}function make_rand($length="32"){//验证码文字生成函数 $str="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $result=""; for($i=0;$i<$length;$i++){ $num[$i]=rand(0,25); $result.=$str[$num[$i]]; } return $result;}//输出调用$checkcode = make_rand(4);session_start();//将随机数存入session中$_SESSION['helloweba_gg']=strtolower($checkcode);getAuthImage($checkcode);?>
windows的服务器可以. 就是ubuntu 不行
检查你的字体文件路径.
你把 62 行的 Header("Content-type: image/JPEG"); 注释掉就能看到错误信息了
ttf 是 windows 的字体文件,你需要安装支持库
内容总结
以上是互联网集市为您收集整理的ubuntu的PHP服务器,验证码图片不显示字符,怎么回事全部内容,希望文章能够帮你解决ubuntu的PHP服务器,验证码图片不显示字符,怎么回事所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。