Use of output buffering and a question about fixing a notice.

From: Eamon Reyn (eamonreyn_at_clear.net.nz)
Date: 05/31/04


Date: 30 May 2004 22:10:03 -0700

Hi People,

I am working on a PHP application that was designed with output
buffering on and am wondering if this was the best approach. The
reason I have started wondering about the wisdom of the decision is
when I moved the application to a machine with a newer version of PHP
on it I started getting bugs that went away when I switched on output
buffering (using output_buffering = 4096).

Any reading suggestions would be appreciated as well as general
opinions.

As well as that I have the following code throwing a notice and am
wondering about the best way to fix it.

I have a form which requires user input, if the input is invalid the
form re-displays with the same data and error messages where
appropriate.

the problem occurs with this code:

<input type="radio" name="optCondition" value="all"
<?php
   if ($optCondition == "all"){
      print "checked";
   }
?>

because $optCondition is not declared the page throws a notice about
it however if I do the following:

<input type="radio" name="optCondition" value="all"
<?php
   $optCondition = "";
   if ($optCondition == "all"){
      print "checked";
   }
?>

the condition is going to get overwritten with an empty string and
spoil my test (I assume). Any Ideas would be appreciated.

I am sorry the first part of this message is a little vague but I hope
someone will pick up what I mean and be able to help.

Thanks,
Eamon.



Relevant Pages

  • Re: headers sent issue
    ... PHP isn't broken. ... It shouldn't have output buffering by default - no ... With the exception of the ease of programming and the speed of getting ... I hope you don't have such a cavalier attitude towards your DBA work as ...
    (comp.lang.php)
  • Re: Read *parsed* PHP file into a variable?
    ... So far so easy - but now the HTML contains ... > a line of PHP. ... > heredoc also doesnt help. ... Sounds like you could use buffering. ...
    (comp.lang.php)
  • Re: [PHP] Cookies and sent headers
    ... 99% of the world never calls ob_flush since PHP flushes the buffer automatically at the end of its execution. ... Cookies are actually headers aswell as any headers set via php's headerfunction. ... why does output buffering help here? ...
    (php.general)
  • Re: [PHP] APC & FastCGI != upload progress ?
    ... I think FastCGI is buffering the upload, which is good I guess, just ... I'll put a comment in the php manual. ... Actually I have been using that for a upload progress meter among other ...
    (php.general)
  • Re: Pushing the limit of PHP vs ASP.NET
    ... "buffering" in App Option in IIS, ... the 150 MB file to your local HDD? ... PHP worked it out without problem, even under Apache for Win32, I am very ... > turn off page buffering to match php performance. ...
    (microsoft.public.dotnet.framework.aspnet)