Questions about php plotting

Source: Internet
Author: User
Php plotting questions? The problem is as follows: 1 & nbsp; attention. phpif (! Defined ('Inc _ check') {die ("error! ") ;}2 & nbsp; globals. phprequire & nbsp; 'attention. php'; // delete this sentence. is the verification code Image correct?
The problem is as follows:
1 attention. php
If (! Defined ('Inc _ check '))
{
Die ("error! ");
}
2 globals. php
Require 'attention. php'; // delete this sentence. the verification code image is normal, otherwise it is invalid.
Function code ()
{
// For the verification code plotting program, see the remarks
}
3 code. php
Define ('Inc _ check', 1 );
Require 'globals. php ';
Code ();
Note:
$ _ Mt_randcode = "";
$ Width = 75;
$ Height = 25;
For ($ I = 0; $ I <4; $ I ++)
{
$ _ Mt_randcode. = dechex (mt_rand (0, 15 ));
}
Session_start ();
$ _ SESSION ['checkcode'] = $ _ mt_randcode;
$ Im = imagecreatetruecolor ($ width, $ height );
Header ("Content-Type: image/png ");
$ White = imagecolorallocate ($ im, 255,255,255 );
$ Black = imagecolorallocate ($ im, 0, 0, 0 );
Imagefill ($ im, 0, 0, $ white );
Imagerectangle ($ im, 1, 1, $ width-1, $ height-1, $ black );
For ($ I = 0; $ I <6; $ I ++)
{
$ _ Rnd_color = imagecolorallocate ($ im, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
Imageline ($ im, mt_rand (0, 75), mt_rand (0, 75), mt_rand (0, 75), mt_rand (0, 75), $ _ rnd_color );
}
For ($ I = 0; $ I <15; $ I ++)
{
Imagestring ($ im, 1, mt_rand (0, $ width), mt_rand (0, $ height), **, imagecolorallocate ($ im, mt_rand (100,200 ), mt_rand (100,150), mt_rand (100,200 )));
}
For ($ I = 0; $ I {
Imagestring ($ im, mt_rand (3, 5), $ I * $ width/4 + mt_rand (0, 10), mt_rand (1, $ height/2 ), $ _ SESSION ['checkcode'] [$ I], imagecolorallocate ($ im, mt_rand (0,255), mt_rand (0,150), mt_rand (0,200 )));
}
Imagepng ($ im );
Imagedestroy ($ im); php image session
------ Solution --------------------
Does the attention. php file have a BOM header?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.