Re: [PHP] Re: Buffering output to allow headers late in code?
> > > Then someone said that using buffering was a bad idea and I should disable > it. > > I think it leads to poor habits like calling controller methods out of the view (essentially what you are wanting to use it for). Using it like that is asking for spaghetti code that's hard to maintain, scale, and train new developers on. I'd imagine it also adds overhead, though I don't know how much - my guess is negligible. OB can be a great tool, but it shouldn't be a hack to get around sloppy architecture. Just my 2 cents :) Chris.
[PHP] Re: Buffering output to allow headers late in code?
Peter Lind wrote: Just out of curiosity: why were you told to switch off output buffering? Regards Peter I can't find the thread now, but it was in regards to my early experiments with cookies. I was creating cookies and it worked mid-code, since buffering was active. Then someone said that using buffering was a bad idea and I should disable it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffering output to allow headers late in code?
Just out of curiosity: why were you told to switch off output buffering? Regards Peter -- WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffering output to allow headers late in code?
On 14 October 2010 15:09, Richard Quadling wrote: > then that is _PROBABLY_ of for a small one of script or a very very "... _PROBABLY_ ok ..." -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffering output to allow headers late in code?
On 14 October 2010 15:01, MikeB wrote: > chris h wrote: >>> >>> >>> I'm working through my class on PHP and I tried to put information from >>> my >>> sign-on process in the navbar. This didn't work well, since I had to >>> reload >>> the page to see it as the navbar was constructed earlier in the code than >>> the signon process. (Hard to explain, as we are building a "dynamic" web >>> page with lots of include files to fill in the main contnt portion of the >>> page.) >>> >>> >> I don't know if this will be much help, but I try to do all the controller >> / >> model work before I mess with the view side. So the controller starts off >> with the ball, then he and the model pass it between each other a few >> times >> until the controller finally hands it over to the view, who does her magic >> and makes the score! ... Perhaps that analogy went to far. >> >> At any rate! Ideally the sign-on task would be done before any tasks that >> would use sign-on data. Additionally, the layout of your page should >> not necessarily dictate the order of any tasks (i.e. the sign-on box being >> below the welcome box should not mean that the sign-on task gets done >> before >> the welcome task). >> >> >> Hope that helps! >> Chris. >> > > I guess that is kind of how I was thinking I might have to rewrite the code > - but that seems to be a major departure from the current "architecture" of > the website we're developing in the course and I'm kind of worried that it > might get harder and harder to follow along in the lessons if I deviate too > much. If your code is being developed along the lines of ... then that is _PROBABLY_ of for a small one of script or a very very small amount of code. But for most long term development, this isn't a nice way to work. Many developers don't like mixing things up. A mechanism I employ that helped me when I started working with PHP is to only have 1 echo statement in the entire page. That way, headers, cookies, etc. can all take place as they need to but only at the end of the script is the content released to the client. In effect, I was doing my own output buffering. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Buffering output to allow headers late in code?
chris h wrote: I'm working through my class on PHP and I tried to put information from my sign-on process in the navbar. This didn't work well, since I had to reload the page to see it as the navbar was constructed earlier in the code than the signon process. (Hard to explain, as we are building a "dynamic" web page with lots of include files to fill in the main contnt portion of the page.) I don't know if this will be much help, but I try to do all the controller / model work before I mess with the view side. So the controller starts off with the ball, then he and the model pass it between each other a few times until the controller finally hands it over to the view, who does her magic and makes the score! ... Perhaps that analogy went to far. At any rate! Ideally the sign-on task would be done before any tasks that would use sign-on data. Additionally, the layout of your page should not necessarily dictate the order of any tasks (i.e. the sign-on box being below the welcome box should not mean that the sign-on task gets done before the welcome task). Hope that helps! Chris. I guess that is kind of how I was thinking I might have to rewrite the code - but that seems to be a major departure from the current "architecture" of the website we're developing in the course and I'm kind of worried that it might get harder and harder to follow along in the lessons if I deviate too much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php