Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: any thoughts on this error?

  1. #11
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by ice
    Or you just start your PHP Script with this:
    PHP Code:
    <?php
    ob_start
    ();
    and end it with this:
    PHP Code:
    ob_end_flush();
    ?> 
    You don't want to do that unless you have to. It will slow down the script.

  2. #12
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126
    [Using output buffering] You don't want to do that unless you have to. It will slow down the script.
    I would disagree with that statement for three reasons (though it's not necessarily an exhaustive list):

    1. By buffering data, the preprocessor can send data to the server in large segments, rather than piecemeal.
    2. Output buffering allows filters to be applied that might not otherwise be possible. An obvious example is compression. Though it's not necessary to compress output, the benefits typically outweigh any possible performance penalty.
    3. Output buffering provides the opportunity for the script to determine the content length and set the corresponding Content-Length header. Without this header, the connection must be closed in order to signal the end of the entity. Any further requests must establish another connection, rather than using persistent connections defined by HTTP/1.1.

    If anything, the use of output buffering should be common practice, not something to avoid. In fact, output buffering is enabled by default in the recommended configuration to accumulate writes into 4kB chunks.

    Mike

  3. #13
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In the case of using it to avoid having to correctly place header() calls, however, it could lead to difficult-to-read code, so I would not recommend using it for expressly this purpose.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #14
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    In the case of using it to avoid having to correctly place header() calls, however, it could lead to difficult-to-read code, so I would not recommend using it for expressly this purpose.
    Surely that's an issue of code design though, not output buffering itself. Of course, if simple language constructs permit the correct and timely sending of HTTP headers then there's no point of explicitly introducing buffering, but the same can be said in any instance where something is used without any tangible benefits.

    Mike

  5. #15
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Indeed so. That's what I was trying to point out: that abusing output buffers in this way would likely lead to poor code design.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #16
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Ok,I'm confused.I thought output buffering would slow things down because I read this in the php.ini filer.

    ; Output buffering allows you to send header lines (including cookies) even
    ; after you send body content, at the price of slowing PHP's output layer a
    ; bit. You can enable output buffering during runtime by calling the output
    ; buffering functions.

    but early it says this

    ; - output_buffering = 4096 [Performance]
    ; Set a 4KB output buffer. Enabling output buffering typically results in less
    ; writes, and sometimes less packets sent on the wire, which can often lead to
    ; better performance. The gain this directive actually yields greatly depends
    ; on which Web server you're working with, and what kind of scripts you're using.

    So is output buffering faster or slower?

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In 90% of cases, faster. Read mwinter's post.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •