Php outputs digital code as an image-PHP source code

Source: Internet
Author: User
Ec (2); defines the output as the image type $ n10; variable $ n is the number of digits of the display. Use the above method to obtain the number of accessors and assign the value to the variable $ str1 (Program omitted) $ str1 $ count; $ str2 & quot; fill in 0 $ len1strlen ($ str1); for ($ i1; $ I & lt; $ n; $ I ++) {$ str2 & quot; 0 & quo script ec (2); script

// Define output as image type
$ N = 10;
// Variable $ n is the number of digits displayed

// Use the above method to obtain the number of accessors and assign the value to the variable $ str1 (Program omitted)
$ Str1 = $ count;
$ Str2 = "";
// If the number of digits is less than $ n, add 0 in front.
$ Len1 = strlen ($ str1 );
For ($ I = 1; $ I <= $ n; $ I ++ ){
$ Str2 = "0". $ str2;
};
// Get $ n Bit 0
$ Len2 = strlen ($ str2 );
// Calculate the number of visits
$ Dif = $ len2-$ len1;
$ Rest = substr ($ str2, 0, $ dif );
$ String = $ rest. $ str1;
// If the number of digits is less than $ n, add 0 in front.
For ($ I = 0; $ I <= $ n-1; $ I ++ ){
$ Str [$ I] = substr ($ string, $ I, 1 );
};
// Store each number in an array
$ Font = 4;
// Define the font size
$ Im = imagecreate ($ n * 11-1, 16 );
// Create an image
$ Black = ImageColorAllocate ($ im, 0, 0 );
$ White = ImageColorAllocate ($ im, 255,255,255 );
// Define the color
Imagefill ($ im, 0, 0, $ black );
// Set the background color of the counter to black.
ImageString ($ im, $ font, 1, 0, $ str [0], $ white );
For ($ I = 1; $ I <= $ n-1; $ I ++ ){
Imageline ($ im, $ I * 11-, $ I * 11-, $ white );
ImageString ($ im, $ font, $ I * 11 + 1, 0, $ str [$ I], $ white );
};
// Write each image and separate it with a vertical line
ImageGif ($ im );
// Image output
ImageDestroy ($ im );
// Release the image

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.