Image Download-PHP header () function picture output problem

Source: Internet
Author: User

**

Recently in self-study PHP encountered a little problem, beg all the way hero, thank you!

**
The first case is normal, there is no content output in front of the header (), the picture can be displayed normally after downloading.

The second is the code that needs to be output before the header (). The Ob_start () input cache is set according to the online method. Images cannot be displayed after they are downloaded:

The php.ini output_buffering is configured as follows:

And the same picture according to the above way to download separately, the size of the picture, MD5 value is not the same, degrees Niang no fruit.
What is the cause of the great God, please?

Reference text

Reply content:

**

Recently in self-study PHP encountered a little problem, beg all the way hero, thank you!

**
The first case is normal, there is no content output in front of the header (), the picture can be displayed normally after downloading.

The second is the code that needs to be output before the header (). The Ob_start () input cache is set according to the online method. Images cannot be displayed after they are downloaded:

The php.ini output_buffering is configured as follows:

And the same picture according to the above way to download separately, the size of the picture, MD5 value is not the same, degrees Niang no fruit.
What is the cause of the great God, please?

Reference text

The header function cannot have any character output until it is used.
If you are unsure, use ob_end_clean(); //清空缓冲区并关闭输出缓冲 the function to empty the previous output before using the character output.

None ...

Look at the encoding format of the file, many of these problems are due to the reason why the UTF-8 has a BOM ...

Of course this is going to go wrong because ... hello was also saved as part of the file, contaminated

Now it's understood that the OB startoutput cache has been misunderstoodbefore-the code for OB start and flush straight executes the sentence behind them after the header is output, and should be followed from Ob_start. In this case, the echo content is exported, covering the contents of the back ReadFile ~

  • 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.