Basic usage getting content between buffers and clearing

suggest change

Output buffering allows you to store any textual content (Text, HTML) in a variable and send to the browser as one piece at the end of your script. By default, php sends your content as it interprets it.

<?php

// Turn on output buffering
ob_start();

// Print some output to the buffer (via php)
print 'Hello ';

// You can also `step out` of PHP
?>
<em>World</em>
<?php
// Return the buffer AND clear it
$content = ob_get_clean();

// Return our buffer and then clear it
# $content = ob_get_contents();
# $did_clear_buffer = ob_end_clean();

print($content);

#> "Hello <em>World</em>"

Any content outputted between ob_start() and ob_get_clean() will be captured and placed into the variable $content.

Calling ob_get_clean() triggers both ob_get_contents() and ob_end_clean().

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Output buffering:
* Basic usage getting content between buffers and clearing

Table Of Contents
2 Arrays
4 Types
10 Cookies
13 Output buffering
14 JSON
15 SOAP
17 cURL
19 XML
21 Traits
35 UTF-8
36 URLs
38 PHPDoc
41 Loops
44 Closur
72 YAML
77 Cache
78 Streams
81 PDO
82 SQLite3
83 Sockets
87 MongoDB
93 IMAP
94 Redis
95 Imagick
102 APCu
108 PSR