Several common examples of php buffer technology

Source: Internet
Author: User
& Lt ;? Php initializes sessionsession_start (); adds the urlrewrite value output_add_rewrite_var (& amp; 39; var & amp; 39;, & amp; 39; value & amp; 39 ;); insert a Connection echo & amp;
  1. // Initialize the session
  2. Session_start ();
  3. // Add the url rewrite value
  4. Output_add_rewrite_var ('Var ', 'value ');
  5. // Insert a connection
  6. Echo 'link ';
  7. // Send the buffer data
  8. Ob_flush ();
  9. // Reset the url rewrite value
  10. Output_reset_rewrite_vars ();
  11. // Insert a connection
  12. Echo 'link ';
  13. /*
  14. */
  15. Print_r (ob_list_handlers (); // lists the output handles used and outputs the default output handler.
  16. Ob_end_flush (); // send the buffer data and disable the buffer.
  17. Ob_start ("ob_gzhandler"); // open the buffer and use ob_gzhandler
  18. Print_r (ob_list_handlers (); // list the output handle.
  19. Ob_end_flush (); // send the buffer data and disable the buffer.
  20. Ob_start (create_function ('$ string', 'return $ string;'); // open the buffer
  21. Print_r (ob_list_handlers (); // lists the output handles used and outputs the default output handler.
  22. Ob_end_flush (); // send the buffer data and disable the buffer.
  23. /*
  24. */
  25. If (ob_get_level () = 0) // judge the buffer level. if no active buffer is available
  26. Ob_start (); // open the buffer
  27. For ($ I = 0; $ I <10; $ I ++) // executes the operation cyclically.
  28. {
  29. Echo"
    Line to show. "; // Output Content
  30. Echo str_pad ('', 4096)." n "; // output the generated string
  31. Ob_flush (); // sends the buffer data
  32. Flush (); // refresh the buffer
  33. Sleep (1); // pause for 1 second
  34. }
  35. Echo "done."; // Mark the output operation
  36. Ob_end_flush (); // sends the buffer data and closes the buffer.
  37. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.