[PHP] ob_start(ob_gzhandler) producing garbage before document header

2009-01-18 Thread Graham Anderson
Hi, using ob_gzhandler  produces a 5-8 characters,  
�“×2���, before the document header.

Using ob_start() does not produce the text garbage.

Is there a way to get ob_start(ob_gzhandler) to behave?

Many thanks in advance



Abridged Code:
ob_start(ob_gzhandler); //produces initial text garbage
# ob_start() //Produces No initial text garbage

# Cache the output
$data = ob_get_contents();

//ob_end_clean(); Can't seem to make this work with ob_gzhandler


# Remove any whitespace that screws up the headers (cannot modify  
headers error)

print trim($data);

# Flush in all ways known to man
flush(); ob_flush(); ob_end_flush();
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start: Capturing STDOUT and STDERR

2008-03-23 Thread Greg Sims
Hey There,

I looked at the ob_start manual and found a segment of code that can be used
to capture the output of a shell script and place it into a log file.  One
of the entries indicates this should work for both STDOUT and STDERR
(29-Mar-2007).  I wrote the following piece of code to test it out.

function logger($buffer)
  {
$handle = fopen('/var/log/test.log', 'a');
fwrite($handle, $buffer);
fclose($handle);
  }

  ob_start(logger);

This will capture the output buffer until the shell terminates when the
buffer is dumped to the test.log file.  This is a simple mechanism and it
works really well to keep STDOUT from going to the console and logging it.
Unfortunately, STDERR continues to go to the console which is what I am
working to avoid.  

I would like to capture STDOUT and STDERR using this technique. I am working
to create a self contained script that does not rely on some external script
to capture the output.  The actual application needs to perform some
post-processing of the output buffer at the end of the script.

Any pointers in the correct direction would be helpful!  Thanks, Greg


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start: Capturing STDOUT and STDERR

2008-03-23 Thread Casey
On Sun, Mar 23, 2008 at 6:08 PM, Greg Sims [EMAIL PROTECTED] wrote:
 Hey There,

  I looked at the ob_start manual and found a segment of code that can be used
  to capture the output of a shell script and place it into a log file.  One
  of the entries indicates this should work for both STDOUT and STDERR
  (29-Mar-2007).  I wrote the following piece of code to test it out.

  function logger($buffer)
   {
 $handle = fopen('/var/log/test.log', 'a');
 fwrite($handle, $buffer);
 fclose($handle);
   }

   ob_start(logger);

  This will capture the output buffer until the shell terminates when the
  buffer is dumped to the test.log file.  This is a simple mechanism and it
  works really well to keep STDOUT from going to the console and logging it.
  Unfortunately, STDERR continues to go to the console which is what I am
  working to avoid.

  I would like to capture STDOUT and STDERR using this technique. I am working
  to create a self contained script that does not rely on some external script
  to capture the output.  The actual application needs to perform some
  post-processing of the output buffer at the end of the script.

  Any pointers in the correct direction would be helpful!  Thanks, Greg


  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



You could use set_error_handler() and make your own function to echo
out the error.

-- 
-Casey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start eval?

2007-07-05 Thread blackwater dev

I have a template system that takes some data, scrubs it and then with a
load method includes the required template.  I need to add a param so it
doesn't simply include but returns the contents of the template in a string
with all of the vars populated.  I tried:

ob_start();
 include my template
$template=ob_get_contents();
ob_clean();
return $template;

But this returns the template it's it's raw for with all of tha
?=$whatever? tags.  Can I fill these in and still pass as another var
without using eval()?

What do other template systems to do return a template as a string on load?


Thanks!


Re: [PHP] ob_start eval?

2007-07-05 Thread Larry Garfield
If I understand what you're doing correctly, then it should work and I've done 
it many times.  First thing you should do, though, is switch from short tags 
to proper tags, ?php echo $whatever; ?.  If you have short tags disabled, 
it will not parse ?= syntax.

On Thursday 05 July 2007, blackwater dev wrote:
 I have a template system that takes some data, scrubs it and then with a
 load method includes the required template.  I need to add a param so it
 doesn't simply include but returns the contents of the template in a string
 with all of the vars populated.  I tried:

 ob_start();
   include my template
 $template=ob_get_contents();
 ob_clean();
 return $template;

 But this returns the template it's it's raw for with all of tha
 ?=$whatever? tags.  Can I fill these in and still pass as another var
 without using eval()?

 What do other template systems to do return a template as a string on load?


 Thanks!


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start eval?

2007-07-05 Thread blackwater dev

We have short tags enabled as our templates work fine with them.

Thanks!

On 7/5/07, Larry Garfield [EMAIL PROTECTED] wrote:


If I understand what you're doing correctly, then it should work and I've
done
it many times.  First thing you should do, though, is switch from short
tags
to proper tags, ?php echo $whatever; ?.  If you have short tags
disabled,
it will not parse ?= syntax.

On Thursday 05 July 2007, blackwater dev wrote:
 I have a template system that takes some data, scrubs it and then with a
 load method includes the required template.  I need to add a param so it
 doesn't simply include but returns the contents of the template in a
string
 with all of the vars populated.  I tried:

 ob_start();
   include my template
 $template=ob_get_contents();
 ob_clean();
 return $template;

 But this returns the template it's it's raw for with all of tha
 ?=$whatever? tags.  Can I fill these in and still pass as another var
 without using eval()?

 What do other template systems to do return a template as a string on
load?


 Thanks!


--
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]  ICQ: 6817012

If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the
possession
of every one, and the receiver cannot dispossess himself of it.  --
Thomas
Jefferson

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start(ob_gzhandler) and error handling functions

2006-12-21 Thread IG

Hi again,

Just wandering if someone could help me on this one- I'm quite anxious 
to get something together. As I said in the last email I just want to 
use ob_start(ob_gzhandler) but it doesn't seem to work with the error 
function. I think it might be something to do with not being allowed 
within a 'callback function'- well that's what it says on the php 
manual. The thing is I'm not sure what that means, I find that section 
not particularly clear. Please can someone help!


IG wrote:

Hi,

I include a php file at the beginning of every web page in this site. 
This include file has an error handling function and starts output 
buffering...


// Start of Error Handler
error_reporting(E_ALL ^ E_NOTICE);
ini_set('log_errors','1');

function ErrHandler($err,$err_string='',$err_file,$err_line)
   {
   // Do error logging thang

   ob_end_clean();// Clear buffer
 include('/path/incs/errors/errors.inc');// Output friendly 
error page

   exit();
   }  
set_error_handler('ErrHandler');


// End of Error Handler

It works great and the error handler kicks in if there is an error on 
the page and outputs a friendly page instead. I really wanted to gzip 
the pages by using ob_start(ob_gzhandler) but it doesn't work. I think 
it is because of the error handler function trying to clear the buffer 
(see the line ob_end_clean() which I assume becomes 
ob_end_clean(ob_gzhandler) ). It says on the php functions page- 
*ob_start()* may not be called from a callback function. If you call 
them from callback function, the behavior is undefined. If you would 
like to delete the contents of a buffer, return  (a null string) from 
callback function.


As I am new to this- I don't really understand what it is trying to get 
at. Is there a way of me using my error handler and evoking the 
ob_start(ob_gzhandler) ?


Thanks.

Ianob_




|ob_start(ob_gzhandler);|



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start(ob_gzhandler) and error handling functions

2006-12-21 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-20 14:12:11 +:
 I include a php file at the beginning of every web page in this site. 
 This include file has an error handling function and starts output 
 buffering...
 
 // Start of Error Handler
 error_reporting(E_ALL ^ E_NOTICE);
 ini_set('log_errors','1');
 
 function ErrHandler($err,$err_string='',$err_file,$err_line)
{
// Do error logging thang
 
ob_end_clean();// Clear buffer
   
include('/path/incs/errors/errors.inc');// Output friendly error 
 page
exit();
}   
 
 set_error_handler('ErrHandler');
 
 // End of Error Handler
 
 It works great and the error handler kicks in if there is an error on 
 the page and outputs a friendly page instead. I really wanted to gzip 
 the pages by using ob_start(ob_gzhandler) but it doesn't work. I think 
 it is because of the error handler function trying to clear the buffer 
 (see the line ob_end_clean() which I assume becomes 
 ob_end_clean(ob_gzhandler) ). It says on the php functions page- 
 *ob_start()* may not be called from a callback function. If you call 
 them from callback function, the behavior is undefined. If you would 
 like to delete the contents of a buffer, return  (a null string) from 
 callback function.
 
 As I am new to this- I don't really understand what it is trying to get 
 at. Is there a way of me using my error handler and evoking the 
 ob_start(ob_gzhandler) ?

I don't use this stuff myself, but it looks like the second half
of this comment might be applicable to you:
http://cz2.php.net/manual/en/function.ob-end-clean.php#71092

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start(ob_gzhandler) and error handling functions

2006-12-20 Thread IG

Hi,

I include a php file at the beginning of every web page in this site. 
This include file has an error handling function and starts output 
buffering...


// Start of Error Handler
error_reporting(E_ALL ^ E_NOTICE);
ini_set('log_errors','1');

function ErrHandler($err,$err_string='',$err_file,$err_line)
   {
   // Do error logging thang

   ob_end_clean();// Clear buffer
  
   include('/path/incs/errors/errors.inc');// Output friendly error 
page

   exit();
   }   


set_error_handler('ErrHandler');

// End of Error Handler

It works great and the error handler kicks in if there is an error on 
the page and outputs a friendly page instead. I really wanted to gzip 
the pages by using ob_start(ob_gzhandler) but it doesn't work. I think 
it is because of the error handler function trying to clear the buffer 
(see the line ob_end_clean() which I assume becomes 
ob_end_clean(ob_gzhandler) ). It says on the php functions page- 
*ob_start()* may not be called from a callback function. If you call 
them from callback function, the behavior is undefined. If you would 
like to delete the contents of a buffer, return  (a null string) from 
callback function.


As I am new to this- I don't really understand what it is trying to get 
at. Is there a way of me using my error handler and evoking the 
ob_start(ob_gzhandler) ?


Thanks.

Ianob_




|ob_start(ob_gzhandler);|

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start() and a callback function within a class,not updating ob_get_level().

2006-11-22 Thread Mathijs

Richard Lynch wrote:

On Thu, November 16, 2006 7:35 am, Mathijs wrote:

I have a question about ob_start() and ob_get_level().

When i use ob_start(), and then check ob_get_level(), it shows me 1.
This is a normal behavior.

Now when i do the following ob_start(array('ClassName',
'ClassMethod')).
It does execute the methode, but it doesn't update ob_get_level().

Is this a normal behavior?


Can you show us where/how you checked ob_get_level()?

Cuz I don't really understand what the OOP stuff should do for a
callback, and would have to re-read the docs, but my first guess is
you do the ob_get_level() after the buffer is all done and the
callback is finished and gone, so the level is back to 0...



To give an small example see below.
The first file is the class file.
Lets pretend the 'MyFunctions' class is included already.

In index1 the ob_get_level() get the wrong count.
In index2 however the ob_get_level() get the right count.

Example:
--
File: class.MyFunctions.php
--
?php
class MyFunctions {
public static function myObCallback($buffer) {
return 'Samplebr'.$buffer.'brSample';
}

//Several other functions etc.. etc..
}
?

File: index1.php
--
?php
ob_start();
//ob_get_level == 1 - This is correct.
ob_start(array('MyFunctions', 'myObCallback'));
//ob_get_level == 1 - This should be 2.
?

File: index2.php
--
?php
function myObCallback2($buffer) {
return 'Sample2br'.$buffer.'brSample2';
//Or this. Works also.
//return MyFunctions::myObCallback($buffer);
}

ob_start();
//ob_get_level == 1 - This is correct.

ob_start('myObCallback2');
//ob_get_level == 2 - This is correct as it should be.
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start() and a callback function within a class, not updating ob_get_level().

2006-11-16 Thread Mathijs

Hello there,

I have a question about ob_start() and ob_get_level().

When i use ob_start(), and then check ob_get_level(), it shows me 1.
This is a normal behavior.

Now when i do the following ob_start(array('ClassName', 'ClassMethod')).
It does execute the methode, but it doesn't update ob_get_level().

Is this a normal behavior?

Thx in advance.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start session_start

2005-12-07 Thread Joe Harman
Hello,

Something just crossed my mind about using output buffering is
there any reason why you should start a session before calling
ob_start() ???

Just curious which way would be the proper way of doing it... or
doesn't it matter?

Thanks

--
Joe Harman
-
* My programs never have bugs, they just develop random features.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Joe Harman
Okay.. makes sense after you spelled it out to me... LOL... I always
start my session first.. so, that must why i have never had any
problems

Cheers  Thanks!
Joe


On 12/7/05, Zack Bloom [EMAIL PROTECTED] wrote:
 yes, it will display the content in the buffer before creating the session.
 If your session uses cookies (this is usually automatically decided by php)
 it cannot send out the header after the buffer.


 On 12/7/05, Joe Harman [EMAIL PROTECTED] wrote:
 
  Hello,
 
  Something just crossed my mind about using output buffering is
  there any reason why you should start a session before calling
  ob_start() ???
 
  Just curious which way would be the proper way of doing it... or
  doesn't it matter?
 
  Thanks
 
  --
  Joe Harman
  -
  * My programs never have bugs, they just develop random features.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




--
Joe Harman
-
* My programs never have bugs, they just develop random features.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Chris Shiflett

Joe Harman wrote:

Okay...makes sense after you spelled it out to me.


That didn't make sense to me (and I missed the original reply). Mind 
elaborating? :-)


Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Zack Bloom
Sure, ob_start begins a buffer allowing you to display content in the
browser before your script has finished executing.  This is useful when
loading a time intensive page to tell the user to wait.  When you create a
session (provide php is not configured otherwise) php attempts to store a
cookie with the session id that corisponds to the session file on the
server.  If it cannot set this cookie it appends the session id to pages in
the get format.  If you were to call session_start() after the output
buffering, content and consequentially the headers would have been already
sent to the browser.  Since cookies must be set in the headers and the
headers must be set before any content is sent to the page, to use cookie
based sessions you must begin the session before the buffer.

Hope that cleared it up,

Zack Bloom


 On 12/8/05, Chris Shiflett [EMAIL PROTECTED] wrote:

 Joe Harman wrote:
  Okay...makes sense after you spelled it out to me.

 That didn't make sense to me (and I missed the original reply). Mind
 elaborating? :-)

 Chris

 --
 Chris Shiflett
 Brain Bulb, The PHP Consultancy
 http://brainbulb.com/

 --
 PHP General Mailing List ( http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start session_start

2005-12-07 Thread Joe Harman
I guess this was just out of general curiousity... If you started
'session_start()' after 'ob_start()' would the sessions work
correctly? k.. maybe I am still confused... lol... I normally do
session_start() before the ob_start()...


Zack Said : 'yes, it will display the content in the buffer before
creating the session.  If your session uses cookies (this is usually
automatically decided by php) it cannot send out the header after the
buffer.'


So, the question is really... in what order is the best way to do
this... I would think that you always want to start a session first...
but then again, you guys are the experts... i am sure someone knows a
reason when you should not do that.

;o)
Joe




On 12/8/05, Chris Shiflett [EMAIL PROTECTED] wrote:
 Joe Harman wrote:
  Okay...makes sense after you spelled it out to me.

 That didn't make sense to me (and I missed the original reply). Mind
 elaborating? :-)

 Chris

 --
 Chris Shiflett
 Brain Bulb, The PHP Consultancy
 http://brainbulb.com/



--
Joe Harman
-
* My programs never have bugs, they just develop random features.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Curt Zirzow
On Thu, Dec 08, 2005 at 01:23:40AM -0500, Joe Harman wrote:
 
 So, the question is really... in what order is the best way to do
 this... I would think that you always want to start a session first...
 but then again, you guys are the experts... i am sure someone knows a
 reason when you should not do that.

The first thing I would ask is why are you using/need ob_start().

session_start() should be the first thing that happens in most
cases. Since, well, any code that exist is potentially going to
rely on a session state.

If you are trying to use ob_start() to rid of the common error
'headers already sent in some_file.php on line such and such', i
would first consider why that is causing the error and how can you
call session_start() before that happens.

Since '97 i think i've used ob_start twice, in all my php apps, and
that was cause I wanted to filter the output either with tidy or
modify the data in a very obscure way.

Curt.
-- 
cat .signature: No such file or directory

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Chris Shiflett

Zack Bloom wrote:

Sure, ob_start begins a buffer allowing you to display content in
the browser before your script has finished executing.


Calling ob_start() turns on PHP's output buffering. In other words, it 
buffers output from the moment this function is called until the buffer 
is flushed (whether explicitly or because the script finishes).


As long as PHP is buffering the output, the client can't get it.


This is useful when loading a time intensive page to tell the user
to  wait.


I think you might be thinking of flush(), which flushes PHP's output 
buffer as well as the output buffer of the web server (or whatever 
backend PHP is using).



When you create a session (provide php is not configured otherwise)
php attempts to store a cookie with the session id that corisponds
to  the session file on the server. If it cannot set this cookie it
appends the session id to pages in the get format.


Yeah, PHP includes a Set-Cookie header in its response. If 
session.use_trans_sid is enabled, it will also rewrite URLs to include 
the session identifier. When PHP receives a request that includes a 
session identifier, it knows whether the client accepts cookies.


if (session identifier in cookie)
{
cookies enabled
}
elseif (session identifier in URL)
{
cookies disabled
}
else
{
new user
}


If you were to call session_start() after the output buffering,
content and consequentially the headers would have been already
sent to the browser.


Maybe you're getting the buffering and flushing concepts reversed? Think 
of a toilet - buffering is the handle up, and flushing is the handle 
down. :-)


Hope that helps!

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start session_start

2005-12-07 Thread Zack Bloom
I have never tried it but if it did work i doubt it would use cookies, it
would probably pass it in the addresses or throw an error.

On 12/8/05, Joe Harman [EMAIL PROTECTED] wrote:

 I guess this was just out of general curiousity... If you started
 'session_start()' after 'ob_start()' would the sessions work
 correctly? k.. maybe I am still confused... lol... I normally do
 session_start() before the ob_start()...

 
 Zack Said : 'yes, it will display the content in the buffer before
 creating the session.  If your session uses cookies (this is usually
 automatically decided by php) it cannot send out the header after the
 buffer.'
 

 So, the question is really... in what order is the best way to do
 this... I would think that you always want to start a session first...
 but then again, you guys are the experts... i am sure someone knows a
 reason when you should not do that.

 ;o)
 Joe




 On 12/8/05, Chris Shiflett [EMAIL PROTECTED] wrote:
  Joe Harman wrote:
   Okay...makes sense after you spelled it out to me.
 
  That didn't make sense to me (and I missed the original reply). Mind
  elaborating? :-)
 
  Chris
 
  --
  Chris Shiflett
  Brain Bulb, The PHP Consultancy
  http://brainbulb.com/
 


 --
 Joe Harman
 -
 * My programs never have bugs, they just develop random features.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start session_start

2005-12-07 Thread Zack Bloom
Sorry it looked like the rest of your email was part of the previous one.
To answer your question it is better to call session_start() before
ob_start()

On 12/8/05, Zack Bloom [EMAIL PROTECTED] wrote:

 I have never tried it but if it did work i doubt it would use cookies, it
 would probably pass it in the addresses or throw an error.

 On 12/8/05, Joe Harman [EMAIL PROTECTED] wrote:
 
  I guess this was just out of general curiousity... If you started
  'session_start()' after 'ob_start()' would the sessions work
  correctly? k.. maybe I am still confused... lol... I normally do
  session_start() before the ob_start()...
 
  
  Zack Said : 'yes, it will display the content in the buffer before
  creating the session.  If your session uses cookies (this is usually
  automatically decided by php) it cannot send out the header after the
  buffer.'
  
 
  So, the question is really... in what order is the best way to do
  this... I would think that you always want to start a session first...
  but then again, you guys are the experts... i am sure someone knows a
  reason when you should not do that.
 
  ;o)
  Joe
 
 
 
 
  On 12/8/05, Chris Shiflett [EMAIL PROTECTED]  wrote:
   Joe Harman wrote:
Okay...makes sense after you spelled it out to me.
  
   That didn't make sense to me (and I missed the original reply). Mind
   elaborating? :-)
  
   Chris
  
   --
   Chris Shiflett
   Brain Bulb, The PHP Consultancy
   http://brainbulb.com/
  
 
 
  --
  Joe Harman
  -
  * My programs never have bugs, they just develop random features.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 



[PHP] ob_start and ob_get_contents buffering problem

2005-10-07 Thread Dasdan
question:
I try to buffer the output of the 'system/views/main.php' into $contents.
and then do a print.
Problem is that the contents of the system/views/main.php are printed 2
times.
Someone who can explain me?
following the contents of testfile.php and main.php, php.ini settings
concerning ob_ ... functions and the output of the script.

Thanks in advance,

Kevin Wood
http://www.dasdan.be

?php
//  testfile.php
ob_start();
include 'system/views/main.php';
$contents = ob_get_contents();

print 'no output above normally ??? :(';
print $contents;
?

?php
// file  :system/views/main.php

print P1
!DOCTYPE HTML PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

html
head
 titleThe Task List/title
/head
body
div
h3test/h3
p
/body
/html
P1;
?

php.ini settings

output_buffering = Off
output_handler =
zlib.output_compression = Off
implicit_flush = Off



the output :


!DOCTYPE HTML PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

html
head
titleThe Task List/title
/head
body
div
h3test/h3
p

/body
/htmlno output above normally ??? :(!DOCTYPE HTML PUBLIC -//W3C//DTD
XHTML 1.0 Strict//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

html
head
titleThe Task List/title
/head
body
div
h3test/h3
p

/body
/html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-19 Thread Marten Lehmann

Hello!


I'm also guessing that it's the LAST line of the file with the
encodeDomain function in it that you include in your test.php

I'm also guessing that there's a NEWLINE character after the final ?
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.


No, there are no newlines at the end of any files. The problem was a new 
behavior of system() in PHP5:


The system() call also tries to automatically flush the web server's 
output buffer after each line of output if PHP is running as a server 
module.


Obviously system() in PHP5 tries to flush, but because it's wrapped in 
ob_start() end ob_end_clean(), it's doesn't actually do. Unfortunately 
an interal flag in PHP is set to output has been sent anyway (bug?). I 
first changed it to passthru() instead of system(), but maybe I should 
use shell_exec() in the future.


Regards
Marten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-18 Thread Richard Lynch
On Wed, August 17, 2005 10:12 am, Marten Lehmann wrote:
 I have a function catching the output of a script:

 function encodeDomain ($domain) {
  ob_start();
  system(echo '$domain');
  $output = ob_get_contents();
  ob_end_clean();
 }

 And I have a php-script using this function:

 ?

 encodeDomain($domain);
 header(Location: http://www.php.net;);

 ?

 While this worked fine in PHP4, with PHP5.0.4 I always get the
 following
 error:

 Warning: Cannot modify header information - headers already sent in
 test.php on line 4

I'm guessing that the error message has MORE information than that --
like the line number of the file in which the output occurred.

I'm also guessing that it's the LAST line of the file with the
encodeDomain function in it that you include in your test.php

I'm also guessing that there's a NEWLINE character after the final ?
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.

 The redirect works if I don't use the encodeDomain() function. Does
 the
 system-output affect the php-outout status in any way? I checked the
 raw
 http-output and I can see nothing of the output from the
 system()-call.
 Does maybe PHP simply say output has been send although it hasn't
 been
 send actually?

Sort of.

Apache may be buffering output, or you may even have output_buffering
set to on in php.ini or gzip may be involved and buffering or...

But as far as PHP is concerned, the headers went out even if
somebody else somewhere is buffering them and you don't see any
output.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-18 Thread Jasper Bryant-Greene

Richard Lynch wrote:

Warning: Cannot modify header information - headers already sent in
test.php on line 4



I'm guessing that the error message has MORE information than that --
like the line number of the file in which the output occurred.

I'm also guessing that it's the LAST line of the file with the
encodeDomain function in it that you include in your test.php

I'm also guessing that there's a NEWLINE character after the final ?
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.


It'd have to be two NEWLINE characters... PHP eats (does not output) any 
NEWLINE character immediately following a ? closing PHP tag.


Jasper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start changed from php4 to php5?

2005-08-17 Thread Marten Lehmann

Hello,

I have a function catching the output of a script:

function encodeDomain ($domain) {
ob_start();
system(echo '$domain');
$output = ob_get_contents();
ob_end_clean();
}

And I have a php-script using this function:

?

encodeDomain($domain);
header(Location: http://www.php.net;);

?

While this worked fine in PHP4, with PHP5.0.4 I always get the following 
error:


Warning: Cannot modify header information - headers already sent in 
test.php on line 4


The redirect works if I don't use the encodeDomain() function. Does the 
system-output affect the php-outout status in any way? I checked the raw 
http-output and I can see nothing of the output from the system()-call. 
Does maybe PHP simply say output has been send although it hasn't been 
send actually?


Regards
Marten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-17 Thread Rory Browne
This doesn't help with your ob problem, but if you simply want to
capture the output of the system cmd, then you can use $output =
shell_exec($command) instead of system() IIRC.

On 8/17/05, Marten Lehmann [EMAIL PROTECTED] wrote:
 Hello,
 
 I have a function catching the output of a script:
 
 function encodeDomain ($domain) {
 ob_start();
 system(echo '$domain');
 $output = ob_get_contents();
 ob_end_clean();
 }
 
 And I have a php-script using this function:
 
 ?
 
 encodeDomain($domain);
 header(Location: http://www.php.net;);
 
 ?
 
 While this worked fine in PHP4, with PHP5.0.4 I always get the following
 error:
 
 Warning: Cannot modify header information - headers already sent in
 test.php on line 4
 
 The redirect works if I don't use the encodeDomain() function. Does the
 system-output affect the php-outout status in any way? I checked the raw
 http-output and I can see nothing of the output from the system()-call.
 Does maybe PHP simply say output has been send although it hasn't been
 send actually?
 
 Regards
 Marten
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start callback preg_replace

2004-06-02 Thread John Kaspar
Can someone help me with preg_replace?
I want to convert all numbers either 8 or 9 digits in length, into a 
link.  Such that when it sees:

John Doe, 456890123, is a new employee.
It converts it to:
John Doe, a href='employee.html?id=456890123'456890123/a, is a new 
employee.

function callback($buffer) {
  // create id links
  return ???;
}
ob_start(callback);
Thanks much,
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] ob_start callback preg_replace

2004-06-02 Thread Marek Kilimajer
John Kaspar wrote:
Can someone help me with preg_replace?
I want to convert all numbers either 8 or 9 digits in length, into a 
link.  Such that when it sees:

John Doe, 456890123, is a new employee.
It converts it to:
John Doe, a href='employee.html?id=456890123'456890123/a, is a new 
employee.

function callback($buffer) {
  // create id links
  return ???;
}
ob_start(callback);
Thanks much,
John
return preg_replace('/([0-9]{8,9})/',
  'a href=employee.html?id=$1$1/a', $buffer);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] ob_start() and session_start() conflicts

2004-02-17 Thread Duncan
Hi,

I am currently working on a download script, where I use a session 
variable to make sure that the downloaded file cannot be linked directly.
However, this protection is not mandatory, so that a download can also 
be created, which can be initiated via a direct link.

So, I'm using the following for the file download:

   ob_start();
   $filename = $sql_result[0];
   $type = $sql_result[1];
   $path = $sql_result[2];
  
   header(Content-Type: $type);
   header(Content-Disposition: attachment; filename=$filename);
   readfile($path);
   ob_end_flush();

...which is working just fine as a standalone, but as soon as I add

session_start();

before the ob_start() call, then the download is no longer working properly.
The following happens in such a case:
if the browser window was used to click through the script and initiate 
the download, then the file can be downloaded properly.
if a new browser window gets opened and you try to access the file 
download via a direct link, then you get the filename presented for 
download without type and path info, e.g.:

Filename: index.php?cmd=downloadid=12
Type:
Path:
As soon as I comment the session_start(); it's working just fine, though 
and the file can be downloaded properly via direct access.

Am I right to assume, that since the session_start(); is sending headers 
as well, the ob_start cannot work properly anymore?
And since it only happens when you're opening a new window and try to 
access it directly, I assume it's related to the fact, that the session 
gets set at the user end with a cookie and therefor causes the problem?
Would preventing session cookies and using trans_id maybe help here?

Thanks,
Duncan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Ob_start question

2003-09-03 Thread Raditha Dissanayake
Most common cause of this problem is whitespace before the '?'
Beauford.2005 wrote:
I am getting this error:

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/usr/local/apache/php/includes/2004server.inc:24) in
/usr/local/apache/php/includes/restricted.inc on line 5
I have ob_start(); and ob_end_flush(); at the beginning and end of
restricted.inc. Like the following. Could someone explain why I am still
getting the above error. 2004server.inc is just the mysql server
info
TIA

?

ob_start();

session_start();

if(!isset($_SESSION['logged'])) {

   $_SESSION['goto'] = $_SERVER['REQUEST_URI'];

   $url = http://www.mysite.net/login/login.php;;
   header(Location: $url);
}
ob_end_flush();

?

 



--
http://www.raditha.com/php/progress.php
A progress bar for PHP file uploads.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Ob_start question

2003-09-03 Thread Ford, Mike [LSS]
On 03 September 2003 03:11, Beauford.2005 contributed these pearls of
wisdom:

 I am getting this error:
 
 Warning: session_start() [function.session-start]: Cannot send
 session cache limiter - headers already sent (output started at
 /usr/local/apache/php/includes/2004server.inc:24) in
 /usr/local/apache/php/includes/restricted.inc on line 5
 
 I have ob_start(); and ob_end_flush(); at the beginning and
 end of restricted.inc. Like the following. Could someone
 explain why 
 I am still
 getting the above error. 2004server.inc is just the mysql
 server info 

... but, according to the error message, output is started in
2004server.inc, nonetheless -- on line 5, to be precise.  What is on line 5
of 2004server.inc?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Ob_start question

2003-09-03 Thread Beauford.2005
This is line 5.. 

$email_error = BRIf the problem persists email A
HREF=mailto:[EMAIL PROTECTED]Webmaster/A;

but I believe the error message refers to line 5 of restricted.in, not
2004server.inc.

This is line 5 of restricted.inc  session_start();


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] 
Sent: September 3, 2003 5:20 AM
To: 'Beauford.2005'; PHP
Subject: RE: [PHP] Ob_start question


On 03 September 2003 03:11, Beauford.2005 contributed these pearls of
wisdom:

 I am getting this error:
 
 Warning: session_start() [function.session-start]: Cannot send session

 cache limiter - headers already sent (output started at
 /usr/local/apache/php/includes/2004server.inc:24) in 
 /usr/local/apache/php/includes/restricted.inc on line 5
 
 I have ob_start(); and ob_end_flush(); at the beginning and end of 
 restricted.inc. Like the following. Could someone explain why
 I am still
 getting the above error. 2004server.inc is just the mysql
 server info 

... but, according to the error message, output is started in
2004server.inc, nonetheless -- on line 5, to be precise.  What is on
line 5 of 2004server.inc?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS,
LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Ob_start question

2003-09-03 Thread John W. Holmes
Beauford.2005 wrote:

I am getting this error:

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/usr/local/apache/php/includes/2004server.inc:24) in
/usr/local/apache/php/includes/restricted.inc on line 5
I have ob_start(); and ob_end_flush(); at the beginning and end of
restricted.inc. Like the following. Could someone explain why I am still
getting the above error. 2004server.inc is just the mysql server
info
At what point are you including the .inc file, though? You must be 
including it outside of the output buffering function in order to get 
this error.

Either move the inclusion of this file within the output buffering or 
fix whatever is causing output on line 24 of 2004server.inc.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Ob_start question

2003-09-03 Thread Ford, Mike [LSS]
On 03 September 2003 12:50, Beauford.2005 contributed these pearls of wisdom:

 This is line 5..
 
 $email_error = BRIf the problem persists email A
 HREF=mailto:[EMAIL PROTECTED]Webmaster/A;
 
 but I believe the error message refers to line 5 of
 restricted.in, not 2004server.inc. 
 
 This is line 5 of restricted.inc  session_start();

Sorry, my mistake -- the relevant part of the error message is:

(output started at /usr/local/apache/php/includes/2004server.inc:24)

so I should have asked about line *24* of 2004server.inc, not line 5!


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Ob_start question

2003-09-03 Thread Curt Zirzow
* Thus wrote Beauford.2005 ([EMAIL PROTECTED]):
 I am getting this error:
 
 Warning: session_start() [function.session-start]: Cannot send session
 cache limiter - headers already sent (output started at
 /usr/local/apache/php/includes/2004server.inc:24) in
 /usr/local/apache/php/includes/restricted.inc on line 5

As the error says it has to do with line 24 of 2004server.inc.  and
most likely looks like this:

?

EOF

or

? EOF


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Ob_start question

2003-09-03 Thread Beauford.2005
Yep, that's it. I thought I had this as it was working at one time, but
obviously some spaces got added.

Thanks.

-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: September 3, 2003 11:13 AM
To: PHP
Subject: Re: [PHP] Ob_start question


* Thus wrote Beauford.2005 ([EMAIL PROTECTED]):
 I am getting this error:
 
 Warning: session_start() [function.session-start]: Cannot send session

 cache limiter - headers already sent (output started at
 /usr/local/apache/php/includes/2004server.inc:24) in 
 /usr/local/apache/php/includes/restricted.inc on line 5

As the error says it has to do with line 24 of 2004server.inc.  and most
likely looks like this:

?

EOF

or

? EOF


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Ob_start question

2003-09-02 Thread Beauford.2005
I am getting this error:

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/usr/local/apache/php/includes/2004server.inc:24) in
/usr/local/apache/php/includes/restricted.inc on line 5

I have ob_start(); and ob_end_flush(); at the beginning and end of
restricted.inc. Like the following. Could someone explain why I am still
getting the above error. 2004server.inc is just the mysql server
info

TIA


?

ob_start();

session_start();

if(!isset($_SESSION['logged'])) {

$_SESSION['goto'] = $_SERVER['REQUEST_URI'];

$url = http://www.mysite.net/login/login.php;;
header(Location: $url);
}

ob_end_flush();


?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start and transparent sessions 4.3.2

2003-08-26 Thread Miek Lohmann
Hi,

I've got a strange problem with enabled transparent sessions for my scripts.
Before upgrading to PHP 4.3.2 I could use output buffering (ob_start()) and
sessions without problems. Meanwhile with this new version the PHPSESSID is
NOT appended to any link like html - tag (a href or something like that).

I found a solution by writing my own session-handling and using regular
expressions to append the session-id to any link, after outputting the
content of the buffer, but this is not a really good solution, I think.

(Btw. session.use_trans_id is on ;))

Has someone found a solution or has had an equal problem with 4.3.2?



Thanks.

Mike


Mike Lohmann

[werk01]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] ob_start and transparent sessions 4.3.2

2003-08-26 Thread Wouter van Vliet
Hi,

I too am running PHP4.3.2 and never took any notice about the session id's
being appended and stuff .. after reading your message I got a little
alarmed, since I'm also using output buffering. So, I turned off my cookies,
restarted my browser and saw that indeed no session id's were appended. Now,
when I checked php.ini, the value appeared to be '0'. That was quite an
explanation. I changed it to '1' and it all worked.

Maybe this makes your problem a little weirder.. But the problem is not on
the PHP version. You might want to check if session.use_trans_sid is really
set to 'On'. If it is, try changing it to '1', restart apache and see if it
works now. Also, check if your cookies are turned off, since with them
turned on, there's no need for php to add the session ID and thus it won't
happen.

Wouter

 - -Oorspronkelijk bericht-
 - Van: Miek Lohmann [mailto:[EMAIL PROTECTED]
 - Verzonden: vrijdag 22 augustus 2003 18:41
 - Aan: [EMAIL PROTECTED]
 - Onderwerp: [PHP] ob_start and transparent sessions 4.3.2
 -
 -
 - Hi,
 -
 - I've got a strange problem with enabled transparent sessions
 - for my scripts.
 - Before upgrading to PHP 4.3.2 I could use output buffering
 - (ob_start()) and
 - sessions without problems. Meanwhile with this new version the
 - PHPSESSID is
 - NOT appended to any link like html - tag (a href or something
 - like that).
 -
 - I found a solution by writing my own session-handling and using regular
 - expressions to append the session-id to any link, after outputting the
 - content of the buffer, but this is not a really good solution, I think.
 -
 - (Btw. session.use_trans_id is on ;))
 -
 - Has someone found a solution or has had an equal problem with 4.3.2?
 -
 -
 -
 - Thanks.
 -
 - Mike
 -
 -
 - Mike Lohmann
 -
 - [werk01]
 -
 -
 -
 -
 - --
 - PHP General Mailing List (http://www.php.net/)
 - To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start problem

2003-03-22 Thread Larry E. Ullman
Warning: ob_gzhandler() [ref.outcontrol]: output handler 
'ob_gzhandler' cannot
be used twice in /blahblah/includes/bottom.inc on line 25
I can't speak as to why this would only happen occasionally, but I 
believe that you should comment out the output_buffering line in the 
php.ini file when using the ob_gzhandler function. Or so says a 
user-contributed note in the PHP manual...

Larry

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] ob_start problem

2003-03-21 Thread Mr Percival
Hi,

I have a page that has an include at the top of the page and an include at the bottom 
of the page.

in the top include file I have added the command:

ob_start(ob_gzhandler);
in the bottom include I have added:

 ob_end_flush();  -- i thought this was supposed to be run to clean up at the end of 
the page.

Most of the time everything is fine, but on occasions it will give an warning error:

Warning: ob_gzhandler() [ref.outcontrol]: output handler 'ob_gzhandler' cannot be used 
twice in /blahblah/includes/bottom.inc on line 25 

line 25 is the line
ob_end_flush();

I dont understand why it only comes up sometimes and what I am doing for that to 
happen, can anyone help me?

Thanks! :))

-- 
__
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start problem

2003-03-21 Thread Justin French
*guess* you're including the footer twice, or are calling ob_end_flush()
more than once.

not anywhere near sure though!!

Justin

 21/03/03 11:33 PM, Mr Percival ([EMAIL PROTECTED]) wrote:

 Hi,
 
 I have a page that has an include at the top of the page and an include at the
 bottom of the page.
 
 in the top include file I have added the command:
 
 ob_start(ob_gzhandler);
 in the bottom include I have added:
 
 ob_end_flush();  -- i thought this was supposed to be run to clean up at the
 end of the page.
 
 Most of the time everything is fine, but on occasions it will give an
 warning error:
 
 Warning: ob_gzhandler() [ref.outcontrol]: output handler 'ob_gzhandler' cannot
 be used twice in /blahblah/includes/bottom.inc on line 25
 
 line 25 is the line
 ob_end_flush();
 
 I dont understand why it only comes up sometimes and what I am doing for that
 to happen, can anyone help me?
 
 Thanks! :))


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start problem

2003-03-21 Thread Mr Percival
That is what I thought, but it isnt.. after doing some testing it seems to only do it 
the first time the page is loaded in the session, if i hit refresh then the problem 
doesnt occur.
is it possible that it has anything to  do with the session_start and session_name 
that is used at the top of the page before the ob_start is called?


 *guess* you're including the footer twice, or are calling ob_end_flush()
 more than once.
 
 not anywhere near sure though!!
 
 Justin
 
  21/03/03 11:33 PM, Mr Percival ([EMAIL PROTECTED]) wrote:
 
  Hi,
  
  I have a page that has an include at the top of the page and an include at the
  bottom of the page.
  
  in the top include file I have added the command:
  
  ob_start(ob_gzhandler);
  in the bottom include I have added:
  
  ob_end_flush();  -- i thought this was supposed to be run to clean up at the
  end of the page.
  
  Most of the time everything is fine, but on occasions it will give an
  warning error:
  
  Warning: ob_gzhandler() [ref.outcontrol]: output handler 'ob_gzhandler' cannot
  be used twice in /blahblah/includes/bottom.inc on line 25
  
  line 25 is the line
  ob_end_flush();
  
  I dont understand why it only comes up sometimes and what I am doing for that
  to happen, can anyone help me?
  
  Thanks! :))
 

-- 
__
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start -- output buffer problem

2003-03-10 Thread Jim Lucas
because the flush happens after everything is done, including the fputs
thingy.

you have to call ob_get_contents() or something like that.

I always to this

ob_start();

do something

$data = ob_get_contents();
ob_end_clean();

then I work with the $data later.

but if you don't use the ob_get_contents(); or ob_end_clean();  then PHP
waits until everything is done, and then flushes.

Jim
- Original Message -
From: Alex Lance [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, March 09, 2003 2:22 AM
Subject: [PHP] ob_start -- output buffer problem



 Hi all,

 to quote from http://www.php.net/manual/en/function.ob-start.php

  void ob_start ( [string output_callback])
 
  An optional output_callback function may be specified. This function
  takes a string as a parameter and should return a string. The function
  will be called when  ob_end_flush() is called, or when the output
  buffer is flushed to the browser at the end of the request.

 My callback function does not get called unless I manually call
 ob_end_flush().

 I'm not interested in calling ob_end_flush() at all,  I want my callback
 function to be called when the output buffer is flushed to the browser
 at the end of the request so the question is why isn't this happening?

 here's my example:

 ?php

 $x = new test();

 echo hey;

 // IF next line is uncommented so it manually flushes
 // then the finish method WILL get called. But I need
 // get around calling anything at the *end* of a script.

 //ob_end_flush();


 class test {

 var $msg_file = cooked_html/error_log2;

 function test() {
 ob_start(array($this, finish));
 $this-msg(got to initialize);
 }

 function finish($page) {
 $this-msg(GOT TO FINISH!!!);
 return $page;
 }

 function msg ($msg) {
 $msg = \n . exec(date) . ::: . $msg;
 $fp = fopen($this-msg_file, a) or die (cannot open
.$this-msg_file);
 fputs ($fp, $msg, strlen($msg)) or die (cannot write to
.$this-msg_file);
 fclose($fp);
 }

 }

 ?


 But if ob_end_flush() IS called then the error log WILL have the GOT TO
 FINISH message.

 Any ideas on why the output is not being flushed automatically?
 thanks
 Alex




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start -- output buffer problem

2003-03-10 Thread Ernest E Vogelsinger
At 11:22 09.03.2003, Alex Lance said:
[snip]
here's my example:

?php

$x = new test();

echo hey;

// IF next line is uncommented so it manually flushes
// then the finish method WILL get called. But I need
// get around calling anything at the *end* of a script.

//ob_end_flush();


class test {
 ...etc
[snip] 

This won't work anyway since your class test is declared after using it -
it should be the other way 'round:

class test {}
$x = new test();


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start -- output buffer problem

2003-03-09 Thread Alex Lance

Hi all,

to quote from http://www.php.net/manual/en/function.ob-start.php

 void ob_start ( [string output_callback])

 An optional output_callback function may be specified. This function
 takes a string as a parameter and should return a string. The function
 will be called when  ob_end_flush() is called, or when the output
 buffer is flushed to the browser at the end of the request.

My callback function does not get called unless I manually call
ob_end_flush().

I'm not interested in calling ob_end_flush() at all,  I want my callback
function to be called when the output buffer is flushed to the browser
at the end of the request so the question is why isn't this happening?

here's my example:

?php

$x = new test();

echo hey;

// IF next line is uncommented so it manually flushes
// then the finish method WILL get called. But I need
// get around calling anything at the *end* of a script.

//ob_end_flush();


class test {

var $msg_file = cooked_html/error_log2;

function test() {
ob_start(array($this, finish));
$this-msg(got to initialize);
}

function finish($page) {
$this-msg(GOT TO FINISH!!!);
return $page;
}

function msg ($msg) {
$msg = \n . exec(date) . ::: . $msg;
$fp = fopen($this-msg_file, a) or die (cannot open .$this-msg_file);
fputs ($fp, $msg, strlen($msg)) or die (cannot write to .$this-msg_file);
fclose($fp);
}

}

?


But if ob_end_flush() IS called then the error log WILL have the GOT TO
FINISH message.

Any ideas on why the output is not being flushed automatically?
thanks
Alex




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start strangness

2003-01-24 Thread Serge Paquin
Hello,

I am trying to get ob_start to work the way I expect but I am running
into some problems.

Take the following example code:


/* Start of code snippet */
function ob_spit_content_length ($buffer) {
$len=strlen($buffer);
if($len0) Header( Content-Length: $len );
return $buffer;
}

if( !function_exists(ob_end_clean_all) ) {
function ob_end_clean_all () {
while ( ob_get_level() ) {
ob_end_clean();
}
}
}

ob_start(ob_spit_content_length);
ob_start(ob_gzhandler);

print There is lots of stuff right here!;

ob_end_clean_all();

/* End of code snippet */

I am running PHP 4.3.0 and my desire is to compress all output (if
browser supports) and also send the content-length header rather than
sending chunked so that my output looks as close to static as possible.

My understanding is that ob_start can be nested and since I registered
ob_spit_content_length first and then ob_gzhandler second that
ob_gzhandler will run first and therefor $buffer being send to
ob_spit_content_length with either be clear text browser does not
support compression or the compress version of the page.  Either way
strlen will get me my length.

Well I get very strang effects and as soon as I comment out my 2 ob_start
calls every think works fine.  Often times op_spit_content_length will
say 0 bytes even though I *KNOW* output was sent.

Am I missing something here?  Did I layer things wrong?  Any suggestions
would be much appreciated.

Thanks,
Serge.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_start

2002-07-14 Thread Kevin Waterson

I wish to compress some data using
ob_start(ob_gzhandler);

I use 
if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'],gzip)) {
 ob_start(ob_gzhandler);
} else {
  ob_start();
}
 but the compression is never used..
obstart is always used withouth the gz_handler
is there a way around this? or am I doing something
wrong here?

Kind regards

kevin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] ob_start

2002-07-14 Thread John Holmes

 I wish to compress some data using
 ob_start(ob_gzhandler);
 
 I use
 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'],gzip)) {

Shouldn't gzip be in quotes, here?? The second argument to strstr...

  ob_start(ob_gzhandler);
 } else {
   ob_start();
 }
  but the compression is never used..
 obstart is always used withouth the gz_handler
 is there a way around this? or am I doing something
 wrong here?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start

2002-07-14 Thread Andrew Brampton

I don't think you need to do the
if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'],gzip)) {
because ob_start(ob_gzhandler); checks to see if the browser will accept
gzip content before gzipping it..

But I think the reason that it isn't working for you is that you don't have
the correct compression libraries compiled into PHP... I spent ages trying
to figure out why mind didn't work and this was the problem. The anonying
thing is that if you don't have this libs it doesn't even tell you

andrew
- Original Message - 
From: Kevin Waterson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 14, 2002 3:34 PM
Subject: [PHP] ob_start


 I wish to compress some data using
 ob_start(ob_gzhandler);
 
 I use 
 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'],gzip)) {
  ob_start(ob_gzhandler);
 } else {
   ob_start();
 }
  but the compression is never used..
 obstart is always used withouth the gz_handler
 is there a way around this? or am I doing something
 wrong here?
 
 Kind regards
 
 kevin
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start

2002-07-14 Thread Kevin Waterson

On Sun, 14 Jul 2002 10:35:13 -0400
John Holmes [EMAIL PROTECTED] wrote:

 Shouldn't gzip be in quotes, here?? The second argument to strstr...

indeed, that fixes that.. thanks

now, I have a problem with mozilla and netscape.
Although they both accept the  ob_start(ob_gzhandler);
netscape gives a comunication error, and mozilla just
a blank page, IE on the Mac however displays the output.

The blank page in mozilla is mentioned in the manual, but
how do get around this??

Kind regards
Kevin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_start('gz_handler') and session_start()

2002-06-05 Thread Jason Caldwell

Is there a way to make ob_start('gz_handler') work with session_start()?

I got them each working independently -- however, when I try to compress a
session -- my page just comes up blank.

?
ob_start('gz_handler');
session_start();

// code and html

ob_end_flush();
ob_end_clean();
?

Or, is there another alternative? -- I'd like to use sessions and I'd
(definitely) like to compress my pages.

Thanks
Jason




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Jason Soza

Just wondering what would cause the following:
I have a 512/128 cable connection through my ISP that I'm hosting my 
sites through. I have a 10gb/mo transfer limit (u/l and d/l) so when I 
saw mention of the ob_gzhandler (and mod_gzip for Apache), that kind of 
got me interested in it.

Anyway, I created a test page, put -just- ?php ob_start(); ? at the 
top, then some lines of HTML, and loaded it. I got all the HTML code 
displayed - shouldn't I have gotten a white screen since I had no ?php 
ob_flush(); ? tag at the bottom? This isn't making sense. Then I tried 
?php ob_start(ob_gzhandler); ? and ?php ob_flush(); ? at the 
bottom - same results.

Am I doing something wrong? Shouldn't the ob_start() by itself just 
load all output into a buffer and not display it until I call ob_flush
()? And how would I know if ob_gzhandler works? I'm running PHP and 
Apache on Windoze, PHP is version 4.2.0 I think, Apache is 
1.3.something.

TIA

Jason Soza



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Robert Cummings

Jason Soza wrote:
 
 Just wondering what would cause the following:
 I have a 512/128 cable connection through my ISP that I'm hosting my
 sites through. I have a 10gb/mo transfer limit (u/l and d/l) so when I
 saw mention of the ob_gzhandler (and mod_gzip for Apache), that kind of
 got me interested in it.
 
 Anyway, I created a test page, put -just- ?php ob_start(); ? at the
 top, then some lines of HTML, and loaded it. I got all the HTML code
 displayed - shouldn't I have gotten a white screen since I had no ?php
 ob_flush(); ? tag at the bottom? This isn't making sense. Then I tried
 ?php ob_start(ob_gzhandler); ? and ?php ob_flush(); ? at the
 bottom - same results.
 
 Am I doing something wrong? Shouldn't the ob_start() by itself just
 load all output into a buffer and not display it until I call ob_flush
 ()? And how would I know if ob_gzhandler works? I'm running PHP and
 Apache on Windoze, PHP is version 4.2.0 I think, Apache is
 1.3.something.

If you don't manually flush a buffer I believe it auto flushes
when the preprocessor completes.

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Miguel Cruz

On Fri, 17 May 2002, Jason Soza wrote:
 Am I doing something wrong? Shouldn't the ob_start() by itself just 
 load all output into a buffer and not display it until I call ob_flush
 ()?

Or when you get to the end of execution...

   http://php.net/ob_implicit_flush

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Jason Soza

Hmmm... So if I -wanted- to buffer the entire page using ob_gzhandler, 
I wouldn't use ob_implicit_flush(), correct? Or would this be 
beneficial in this case? The way I read the manual page on 
ob_implicit_flush() is that it flushes after each output call. Would 
that mean that ob_start(ob_gzhandler) would compress the output, then 
ob_implicit_flush() would display that compressed output at each call?

Either way, is there any way to tell if my output is really being 
compressed by ob_gzhandler?

Jason Soza

- Original Message -
From: Miguel Cruz [EMAIL PROTECTED]
Date: Friday, May 17, 2002 10:39 am
Subject: Re: [PHP] ob_start() and ob_gzhandler

 On Fri, 17 May 2002, Jason Soza wrote:
  Am I doing something wrong? Shouldn't the ob_start() by itself 
 just 
  load all output into a buffer and not display it until I call 
 ob_flush ()?
 
 Or when you get to the end of execution...
 
   http://php.net/ob_implicit_flush
 
 miguel
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Rasmus Lerdorf

You can just set output_handler in your php.ini file to automatically
buffer and compress everything.

On Fri, 17 May 2002, Jason Soza wrote:

 Hmmm... So if I -wanted- to buffer the entire page using ob_gzhandler,
 I wouldn't use ob_implicit_flush(), correct? Or would this be
 beneficial in this case? The way I read the manual page on
 ob_implicit_flush() is that it flushes after each output call. Would
 that mean that ob_start(ob_gzhandler) would compress the output, then
 ob_implicit_flush() would display that compressed output at each call?

 Either way, is there any way to tell if my output is really being
 compressed by ob_gzhandler?

 Jason Soza

 - Original Message -
 From: Miguel Cruz [EMAIL PROTECTED]
 Date: Friday, May 17, 2002 10:39 am
 Subject: Re: [PHP] ob_start() and ob_gzhandler

  On Fri, 17 May 2002, Jason Soza wrote:
   Am I doing something wrong? Shouldn't the ob_start() by itself
  just
   load all output into a buffer and not display it until I call
  ob_flush ()?
 
  Or when you get to the end of execution...
 
http://php.net/ob_implicit_flush
 
  miguel
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Jason Wong

On Saturday 18 May 2002 02:48, Jason Soza wrote:

 Either way, is there any way to tell if my output is really being
 compressed by ob_gzhandler?

If you have NN4.X use view source, if the source is empty then compression is 
active.

If you're using some form of un*x then:

  lynx --mime_header http://www.domain.com/page.php

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
If only God would give me some clear sign!  Like making a large deposit
in my name at a Swiss Bank.
- Woody Allen
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_start(ob_gzhandler) and require_once

2002-05-04 Thread bob

can  ob_start(ob_gzhandler) function be nested ?

after echo 'test' ,  does it continue to includes and evaluates c.php?



for example:

a.php
?php 
require_once main.php;
..
include b.php;

?

b.php
?php
require_once main.php;
...
echo 'test';
include c.php;
?

c.php
?php
require_once main.php;
...
?

main.php
?php
ob_start(ob_gzhandler);

?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_start()

2001-09-03 Thread Jeroen Olthof

Can I increase speed by using this to buffer output ?

kind regards
Jeroen Olthof



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]