今天在做一个php验证码程序时发现生成出来的图片不显示,开始以为是php gd库未打开,查用phpinfo查了是可以打开的啊,下面小编来给大家介绍此问题解决办法。
清除了bom,代码也是顶行开始写的,gd库也是开启的,从这里来看估计不是gd库的问题了,可能出在程序那句代码上。
生成验证码的代码:
代码如下 | 复制代码 |
/*
|
感觉是不是没有问题了,后来百度发现一高人说关键是加入了ob_clean,了这个让我想了原因。
解决办法
ob_clean(); //关键代码,防止出现'图像因其本身有错无法显示'的问题。
加到 header 输出之前
代码如下 | 复制代码 |
|

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version
God-level code editing software (SublimeText3)