Storing the execution of an included .php file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Storing the execution of an included .php file

Post by LonelyProgrammer »

Hi, is it possible to store the output of a PHP script into a string? For example:

included.php:

Code: Select all

 
<html>
<?php echo "Hello world"; ?>
</html>
 
and then something like

Code: Select all

 
$included = include("included.php"); // included.php is not output at all
 
Thanks in advance!
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Storing the execution of an included .php file

Post by susrisha »

file_get_content is the function
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Re: Storing the execution of an included .php file

Post by LonelyProgrammer »

Eh, I don't think file_get_contents parse PHP functions inside the file.

I found this on the comments for file_get_contents though

Code: Select all

 
<?php
 
    ob_start();
    include($filename);
    $return_str = ob_get_contents();
    ob_end_clean();
 
?>
 
Post Reply