The PHP verification code is not displayed.

Source: Internet
Author: User
Describe that your problem GD library has been opened. search for solutions from other friends: Clear BOM, ob_clean (), and do not display line breaks at the starting position of the Code. Paste the relevant code {code ...}
  1. Describe that your problem GD library has been opened. search for solutions from other friends: Clear BOM, ob_clean (), and do not display line breaks at the starting position of the Code.

  2. Paste related Code


  

Reply content:
  1. Describe that your problem GD library has been opened. search for solutions from other friends: Clear BOM, ob_clean (), and do not display line breaks at the starting position of the Code.

  2. Paste related Code


  

After testing, your code has the following problems:
When Random underline is implemented, the input parameter of imagecolorallocate is incorrect. Four params should be given, and the current Code gives six parameters.
Result: After modification, the verification code is displayed as normal.

Here, imagecolorallocate should contain four parameters.

I don't understand what you mean. What do you mean?

The result is

Check the error log and try again.

Header ('content-Type: image/png ');

Check the DOM header from all the files in the framework from other places.

Try copying some successful code on the Internet first. If it succeeds, it is your code problem. Otherwise it should be an environment problem.

Is GD not installed? Check phpinfo ()

Clear the output buffer before header,

ob_clean()header('Content-Type:image/png');imagepng($_img);

The final verification code is soy sauce,

So the question is,
1. Why?ob_clean()To addimagepng()Before?
Apparently,header()The previous Code will not be cachedObWhich of the following statements is actually cached to ob?imagepng()The generated verification code. When you refresh the code in the browser,ob_clean()Will clear the previousOb. Thenimagepng()Generate a verification code and save itOb,ObThen it is thrown into the program cache and packaged into the browser.

2. If noob_clean()A verification code will also be generated. Where does the verification code go?
Use php5.4 or earlier or disableOb.

Ps: After php5.3,ob_start()Enabled by default, repeated additionob_start()Will causeob_end_*()Invalid. (Oops .. if the code ob_start is repeatedly edited locally, an error occurs. However, an upload class can run properly. For more information, see .)

First, thank you for helping you modify the code highlight. It won't work if you change it several times. It's used for the first time. Try again.

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.