Jump to content

Output in stages


sphinx9999

Recommended Posts

I need to output data in two stages: I have an advert displaying script with a logger at the end. I am concerned that if my scripts cannot connect quickly to my logging db for any reason, the advert will not be displayed quickly. I need to force the advert to display, irrespective of whether it is logged. I know I should be able to this with output buffers (flush after echo $ad, then log) but this option is not available to me. Any other ways?

Link to comment
https://forums.phpfreaks.com/topic/90506-output-in-stages/
Share on other sites

Unfortunately I cannot use output buffering. I'm really asking if there are any alternatives to it.

 

I know this sounds weird and I'm not sure if it would really work but I've been thinking of something along the lines of echoing out an html javascript tag with the src being another script with the logging functionality in it:

 

echo $ad;
echo '<script type="text/javascript" src="logging.php"></script>

 

logging.php:

<?
//logging functionality here
?>

 

This way all echo's would be performed AND THEN the logging would be done. However, if this works it will only work for an html output - great for my html page but not so good for my xml formatted version... :(

 

Thanx

Link to comment
https://forums.phpfreaks.com/topic/90506-output-in-stages/#findComment-464707
Share on other sites

Yeah, I think buffering is going to be my only hope here - the div solution is good but won't work for my xml formatted page. I'm not sure why my development server is not allowing OBing. It stores the text in the buffer but does not output it seperately from the rest of the text. For example:

 

ob_start();
echo 'test';
ob_end_flush();
sleep(3);
echo 'another test';

 

I would expect 'test' to appear straightaway and then after a 3 second pause 'another test'. However, I just get a three second pause and then both strings appear together. Ho hum...

Link to comment
https://forums.phpfreaks.com/topic/90506-output-in-stages/#findComment-464810
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.