Jump to content

Recommended Posts

I'm having an unusual problem - on my local W.A.M.P.  setup, my header() calls work perfectly well even if I managed to output some text to the browser.  This is confusing, and makes it very hard to debug that particular problem.  (It works even if I create a blatant test case and put it in the center of a page with print('...some HTML...'); statements above and below it works!)

 

I try never to do that, but it happened on one or two occasions, and I never noticed because on my test server, it happily redirects (tested with I.E. 7, 6, 5, and FF 1.5 and 2.0) even though it should simply fail.  It does (of course) fail in the normal ways if I upload to our web host.

 

Is there some PHP setting that might be allowing this?  I'd rather just suffer the error so that I know that I've made a mistake.  Obviously the best thing to do would be "make sure it never happens in the first place," but some of these projects are large and involve a lot of page interactions, and we all make silly mistakes once in a while, don't we?  :)

Link to comment
https://forums.phpfreaks.com/topic/64718-solved-header-problem-in-reverse/
Share on other sites

it's likely the output_buffering setting in php.ini.  with this setting on (it defaults to off, obviously), PHP will capture any output to the browser, run headers at the end of output, followed by flushing the output (thus the term "output buffering").  check phpinfo() to see whether the setting is on and if so, turn it off to trigger the errors.

Thank you - I will at the next opportunity.  I have to wonder why all servers aren't just set up this way though - wouldn't it kind of be "principle of least surprise?"  Especially when the error that normally results is common enough to earn sticky posts in several well-knownforums.

 

Thanks for your help!

if you installed your server from a package, it may simply have been defaulted to "on" by the installer so as to make it work "out-of-the-box" for the largest number of users.  it's counter-intuitive for a good, approximative development environment, so i imagine the package used was one that was tailored to the average joe who just wants to fuddle around, not a serious developer.

 

let's be honest - one isn't truly a developer until they've had the growing pains of installing AMP to work in harmony on their own.  plus, it's a great and not-at-all frustrating experience!

Actually, I installed it a year or so ago from the php site as a zipped package, and it was a small project to get it to work - so I'm probably the one guilty of changing the setting.  At the time I probably some reference in front of me to explain each setting, and without the experience to know that it would cause trouble down the road, I thought it made more sense to set it the way it is.

 

edit: I guess that is why "a little learning is a dangerous thing."

you could look at the silver lining - if this had never happened, you wouldn't have known how to deal with it under potentially more urgent circumstances.  a little learning is only dangerous if one is unwilling to learn beyond that point.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.