A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Waterfall_Cache has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 47

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 194

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Memcache_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 275

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Filesystem_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 440

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; APC_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 628

Output Buffering Page 3

Output Buffering Page 3

By ServerWatch Staff (Send Email)
Posted Sep 7, 2000


With PHP3, all of the content produced by echo () or print() was sent directly to the server. In PHP4, an intermediate storage layer makes it possible to defer the sending the Web server's output flow. To do this, features so new they have yet to be documented, are available:

  • ob_start(): activates output buffering
  • ob_end_flush(): sends the contents of the output buffer and deactivates buffering
  • ob_end_clean(): empties the output buffer and deactivates buffering
  • ob_get_contents(): returns the output buffer contents
This functionality makes it possible to prepare the contents displayed via complex processes requiring several database queries, for example, and the sending of results only when all of the queries have been carried out successfully. In the opposite case, users can empty the output buffer contents and display an error message in its place. The example below shows a typical case of how these functionalities are used:

<?php
// activate output buffers
ob_start();
// the output is not displayed, it enters the buffer print "Hello, world!";
// read buffer contents
$output = ob_get_contents();
// deactivate the buffer, empty the buffer
ob_end_clean();
// display contents
print $output;
?>


Thanks for your registration, follow us on our social networks to keep up-to-date