Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.



Add comment:
Name:
Email:
Comment: *
(Use BBcode - No HTML)


You MUST answer this simple math equation - to prevent spammers: 2 + 12 =  


How can I capture the contents of an included file?

Last updated: 06/30/2009
Usually, when you include a file in Php, any output generated by that script is printed out directly.  However, if you'd like to capture it, say for sending an email message, you can do it like so:



ob_start();
include("filename.php");
$message = ob_get_contents();
ob_end_clean();

$message now contains the output from the included file.  You can send it in an email, or whatever!




Powered by KnowledgebasePublisher 1.1
Superb Internet
Content provided by Roberts WebForge, Inc.