Php uses the gd library to create a verification code without displaying images

Source: Internet
Author: User
I wrote a verification code, but the image cannot be displayed in the local wampsever environment, but it can be displayed when I upload it to the server. The local gd library is a bit confusing for beginners! {Code ...}

A verification code is written, but the image cannot be displayed in the local wampsever environment.

But I uploaded it to the server, but it can be displayed.

The local gd library is open

A beginner gets confused and asks for advice!

    
  

Reply content:

A verification code is written, but the image cannot be displayed in the local wampsever environment.

But I uploaded it to the server, but it can be displayed.

The local gd library is open

A beginner gets confused and asks for advice!

    
  

The image is not displayed because the generated image stream is incorrect. Open the image address in the browser.
You may find that:

phpFatal error :xxxxxx or Warning : xxxxx

Error message.

In addition, display_erorrs is generally enabled locally, but in the server production environment, all error outputs are disabled for security reasons.

  1. Check file encoding,utf-8Usually.
  2. Tryob_clean();To clean the wrong output buffer.

Why is this code so familiar .......!

The subject should be extracted from the PHP e-commerce website development tutorial on MOOC.

This code has a BUG in
$ Fontfiles = array ("SIMYOU. TTF ");
$ Fontfile = '../fonts/'. $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];

In the fonts folder, you have not placed SIMYOU. TTF or other related font files, so the server cannot find the font.

You only need to add the TTF font file.

No other content can be output for the output verification code !!
This is because display_errors is enabled in your local environment,
You only need to be at the top, that is, require_once '.. /include. php'; add ini_set ('display _ errors ', 'off') above this line.
In addition, your

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.