Php performs a verification code. the output image shows garbled characters. how can this problem be solved?

Source: Internet
Author: User
Php performs a verification code. the output image shows garbled characters. how can this problem be solved? Paste the source code:
   
Excuse me !!! This problem has been found many on the Internet, basically with these three errors:
1. a BOM header is available; I have removed it.
2. the GD Library has not been opened; I have already opened
3. no output exists before the header, and I have no output.
Why?


Reply to discussion (solution)

I just tried it. after moving the file for obtaining images to a sub-folder of the project, it will be displayed. I put it directly under the root directory of the project, and the obtained images are garbled. I don't know why. I hope you can share the reason!

VerifyImage function not executed, or spelling error
String. func. php loading failed
BuildRandomString function name spelling error
The font file does not exist.

VerifyImage function not executed, or spelling error
String. func. php loading failed
BuildRandomString function name spelling error
The font file does not exist.


I just moved the file that calls the verifyImage () function from the root directory to the subdirectory. why?

$ Fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];

The file cannot be found because the location has changed.
Can't you store your font files everywhere?

$ Fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];

The file cannot be found because the location has changed.
Can't you store your font files everywhere?


No, my font files are all placed in the fonts folder, and the path cannot be wrong.

Please forgive me for the curse!

It has been several days since I closed my post!


$ Fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];

The file cannot be found because the location has changed.
Can't you store your font files everywhere?


No, my font files are all placed in the fonts folder, and the path cannot be wrong.



Then you know $ fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];
Is this actually a relative path?



$ Fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];

The file cannot be found because the location has changed.
Can't you store your font files everywhere?


No, my font files are all placed in the fonts folder, and the path cannot be wrong.



Then you know $ fontfile = "../fonts/". $ fontfiles [mt_rand (0, count ($ fontfiles)-1)];
Is this actually a relative path?


En, you know. it was originally placed in the root directory and the obtained path is incorrect.
Thank You!

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.