PHPsu
MANUAL ZH  |  EN
     


Current Position :| index>Beginners> Capture the Output

Capture the Output

FROM: AUTHOR: TIME:2008-06-06 HITS:

It is possible to capture the output of an include to a variable. This is useful for caching and code generation. I found this feature when I was creating a code generation script for IFrame.

phpsu is a phpschool

$string = getIncludeContents('template.php');

function getIncludeContents($filename) {
if (is_file($filename)) {
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}
www.phpsu.com

More on include() phpsu提供的php教程


TITLE:Capture the Output
Copyright 2008 The PHPsu All rights reserved. This mirror generously provided by: .Hp Inc.
Last updated: Fri Jun 6 22:59:20 GMT-8 2008