Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-05-2008, 10:48 AM output buffers
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Is there any way to check if an output buffer is activated or not? In one of my classes I run ob_start() in the constructor. In case the function for getting the buffer and ending it hasn't been called when the destructor is called I want the destructor to erase the buffer and end it.

In short, I need some thing like the following
PHP Code:
if ("output buffer is still activated") {
   
ob_end_clean();

Thanks!
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 01-05-2008, 05:50 PM Re: output buffers
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
In the class constructor function, do something like the following:

global $output_buffer;

$output_buffer = true;
ob_start();

. . . .


Then in your other function, check if it is active:

PHP Code:
function outputBuffer()
{
  global 
$output_buffer;
 
  if (isset(
$output_buffer) AND $output_buffer === true)
  {
    return 
true;
  }
  else
  {
    return 
false;
  }

__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-05-2008, 06:02 PM Re: output buffers
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Oh, right. Why didn't I think of that? :P
But I still feel like there probably is some way of calling another ob_something() function to check weather or not it's active. Really doesn't matter though, thanks!
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-05-2008, 08:28 PM Re: output buffers
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
It's just there, in the manual:
http://www.php.net/manual/en/function.ob-get-status.php
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-06-2008, 06:21 AM Re: output buffers
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I acctually looked in the manual, I always do, but couldn't find it. Thanks a lot!
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-06-2008, 05:04 PM Re: output buffers
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
hmmm, I didn't even know that was in there - Thats one thing I like about PHP, it's so packed with built-in features, you can never stop learning new things about it!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to output buffers
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25338 seconds with 12 queries