Codes from my life

Few days back when I was writing some PHP, I found out that

 header( 'location: xyz.php' );

was not working on my hosting. The problem was headers were being sent by the server before processing the entire php. So I added this function at the top of the php file to buffer the output stream,

ob_start();

and the below function at the bottom of the php file to flush the buffer.

ob_end_flush();

This solved my problem.

Advertisements

Comments on: "PHP header redirect problem" (2)

  1. Debayan said:

    For this discovery you have been nominated for http://en.wikipedia.org/wiki/Turing_Award

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: