Questions tagged [ob-get-contents]
47 questions
1
vote
2 answers
Output streaming with PHP ob_start & ob_get_clean
I have a script that echo out content in a php script and resulting in a very large file, e.g. 100MB
Currently I use the following way to capture the output and write to another file
ob_start();
require_once 'dynamic_data.php'; // echo 100MB…

Ryan
- 10,041
- 27
- 91
- 156
1
vote
4 answers
Better HTML within a returning function?
I can write HTML code within a string and return it but it always looks a bit messy. Is there any better solution for this?
Example 1 - New line HTML
New line for every row with HTML. A very messy way to write HTML code.
function my_function()
{
…

Jens Törnell
- 23,180
- 45
- 124
- 206
0
votes
2 answers
Retrieving output from a url. How do I force the dowload of a PDF from a url using php
I need to retrieve our reports from the jasperserver report engine as a PDF, then I want the PDF to be forced as a download, instead of being displayed inthe browser. The problem with displaying in the browser is we don't want the report parameters…

Ronedog
- 2,313
- 8
- 43
- 85
0
votes
1 answer
PHP setting up two output buffers with different contents in while loop
I have a Wordpress site and I am trying to loop over my posts in an AJAX call and I would like to store the HTML for the first post in the loop in a separate variable than the rest of the posts. How would I go about setting up the output buffer
if…

user13286
- 3,027
- 9
- 45
- 100
0
votes
0 answers
ob_get_contents doesnt work when within foreach
Hi,
I have this code which works just fine
function show_aval($place) {
echo $place;
}
ob_start();
show_aval(london);
$show_aval = ob_get_contents();
ob_clean();
ob_start();
show_aval(york);
$show_aval2 =…

Cain Nuke
- 2,843
- 5
- 42
- 65
0
votes
1 answer
How to use ob_get_contents with a function with arguments
I have a function like this:
function show_aval($place) {
//some function
}
I want to translate this into a variable so I do this:
ob_start();
show_aval(london);
$avalrooms = ob_get_contents();
ob_clean();
This will be fine if the argument is…

Cain Nuke
- 2,843
- 5
- 42
- 65
0
votes
0 answers
Capture javascript output in PHP ob_get_clean()?
I'm trying to allow JS to execute inside PHP's output buffering.
I have tried declaring ob_start and then referencing the javascript, then getting the contents