博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php生成验证码 参考PHP手册
阅读量:4602 次
发布时间:2019-06-09

本文共 1423 字,大约阅读时间需要 4 分钟。

视图层 复制粘贴就可以

phpStudy2013 GD支持未开启 解决方法

phpStudyAdmin控制台 - 配置文件 - php.ini
查找“extension=php_gd2.dll”,去掉“extension=php_gd2.dll”前面的“;”,保存
phpStudyAdmin控制台 - MySQL服务 - 重启
phpStudyAdmin控制台 - Apache服务 - 重启
问题解决

 然后进行操作

<?php

 // Set the content-type
 header ( 'Content-Type: image/png charset=utf-8' );
 // Create the image
 $im  =  imagecreatetruecolor ( 100 ,  100 );
 // Create some colors
 $white  =  imagecolorallocate ( $im ,  255 ,  255 ,  255 );
 $grey  =  imagecolorallocate ( $im ,  128 ,  128 ,  128 );
 $black  =  imagecolorallocate ( $im ,  0 ,  0 ,  0 );
 imagefilledrectangle ( $im ,  0 ,  0 ,  399 ,  29 ,  $white );
 // The text to draw
 $text  =  '1231231231231' ;

// $text  =  '1231231231231' ; 是显示的内容

 // Replace path by your own font path
 $font  =  'arial.ttf' ;
 // Add some shadow to the text
 imagettftext ( $im ,  20 ,  0 ,  11 ,  21 ,  $grey ,  $font ,  $text );
 // Add the text
 imagettftext ( $im ,  20 ,  0 ,  10 ,  20 ,  $black ,  $font ,  $text );
 // Using imagepng() results in clearer text compared with imagejpeg()
 ob_clean();
 imagepng ( $im );
 imagedestroy ( $im );
 ?>

!!如果报 不显示 写上 ob_clean();,如果乱码 去掉BOM头(当时不知道,没试过)

 

或者

 

<?php

// 创建新的图像实例

        $im = imagecreatetruecolor(100, 100);
// 设置背景为白色
        imagefilledrectangle($im, 0, 0, 99, 99, 0xFFFFFF);
//在图像上写字
        imagestring($im, 3, 40, 20, 'GD Library', 0xFFBA00);
//GD Library'是输出的内容
// 输出图像到浏览器
        header('Content-Type: image/gif');
        imagegif($im);
        imagedestroy($im);

?>

 

转载于:https://www.cnblogs.com/zhangxuu/p/7053602.html

你可能感兴趣的文章
关于dl dt dd 文字过长换行在移动端显示对齐的探讨总结
查看>>
swoolefy PHP的异步、并行、高性能网络通信引擎内置了Http/WebSocket服务器端/客户端...
查看>>
Python学习笔记
查看>>
unshift()与shift()
查看>>
使用 NPOI 、aspose实现execl模板公式计算
查看>>
行为型模式:中介者模式
查看>>
How to Notify Command to evaluate in mvvmlight
查看>>
33. Search in Rotated Sorted Array
查看>>
461. Hamming Distance
查看>>
Python垃圾回收机制详解
查看>>
{面试题1: 赋值运算符函数}
查看>>
Node中没搞明白require和import,你会被坑的很惨
查看>>
Python 标识符
查看>>
Python mysql 创建连接
查看>>
企业化的性能测试简述---如何设计性能测试方案
查看>>
centos7 安装中文编码
查看>>
POJ - 3683 Priest John's Busiest Day
查看>>
正则表达式start(),end(),group()方法
查看>>
vuejs 学习旅程一
查看>>
javascript Date
查看>>