<?PHP$height= 300;$width= 300;$im= Imagecreatetruecolor ($width,$height);$white= Imagecolorallocate ($im, 255, 255, 255);$blue= Imagecolorallocate ($im, 0, 0, 64); Imagefill ($im, 0, 0,$blue); Imagestring ($im, the ten, the other, the ' hello,php ',$white);Ob_clean();//If the verification code output is not, plus this sentence can be outputHeader(' Content-type:image/png '); Imagepng ($im); Imagedestroy ($im);?>
<?PHP// Bug-free flag test //ob_clean ();Header("Content-type:image/jpeg");$ing= Imagecreatetruecolor (700,410);//Create a new true color image, return a value of an image identifier, default to black on the background, parameter (x_size*y_size)$red= Imagecolorallocate ($ing, 255,0,0);//Define background color$yellow= Imagecolorallocate ($ing, 237,231,32);//Define YellowImagefill ($ing, 0, 0,$red);//fill color, starting with coordinates (0,0), fill//array coordinates, denoted (x1,y1,x2,y2,x3,y3.....x11,y11);$a=Array(90,30,108,73,157,73,119,102,135,152,93,123,52,152,66,102,29,74,76,73,90,30); Imagefilledpolygon ($ing,$a, 10,$yellow);//Draw a polygon: 10 represents the total number of vertices, $yellow represents the fill color$a 1=Array(229,25,229,43,248,48,229,55,229,74,217,60,198,66,210,50,197,34,218,39,229,25); Imagefilledpolygon ($ing,$a 1, 10,$yellow);$a 2=Array(227,108,227,127,245,134,228,139,227,157,215,143,196,149,208,132,196,117,215,122,227,108); Imagefilledpolygon ($ing,$a 2, 10,$yellow);$a 3=Array(163,184,163,204,181,211,163,216,163,234,152,220,132,225,144,209,132,193,151,199,163,184); Imagefilledpolygon ($ing,$a 3, 10,$yellow);$a 4=Array(65,209,65,228,84,235,65,240,65,259,54,245,33,249,46,233,34,217,53,224,68,209); Imagefilledpolygon ($ing,$a 4, 10,$yellow); Imagejpeg ($ing); Imagedestroy ($ing);?>
Note! about the verification code can not be displayed, first determine whether the GD library is open;
The default configuration, the PHP output is the first to the output buffer (output_buffering), as long as the data is not really sent to the browser (strictly speaking TCP buffer), there is still a chance to empty the previous buffer inside the data, using the built-in Ob_clean function.
PHP Verification Code Image error cannot be displayed