Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    compressing, buffering and ob_get_length

    i am using output buffering:
    PHP Code:
    ob_start('ob_gzhandler'

    and at the end i get the data length by calling:
    PHP Code:
    header('Content-length:'.ob_get_length()): 

    but i have a problem: this is size of UNCOMPRESSED data, but i should send only compressed data length. any idea how to fix it?

    thanx!

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    PHP Code:
    ob_start()
    ob_start('ob_gzhandler');
    // content and whatnot;
    ob_end_flush();
    header('Content-Length: ' ob_get_length());
    ob_end_flush(); 
    ... is one alternative.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why to use ob_end_flush twice?
    calling this function sends data to user and destroys buffer, so the second call is useless...

    anyway, you still used the same method as me - user gets length of uncompressed data

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by looka
    why to use ob_end_flush twice?
    I was pulling you leg. I would never post code that I suspect of being correct.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

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