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
LonelyProgrammer
Forum Contributor
Posts: 108 Joined: Sun Oct 12, 2003 7:10 am
Post
by LonelyProgrammer » Mon Mar 23, 2009 10:40 pm
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!
susrisha
Forum Contributor
Posts: 439 Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India
Post
by susrisha » Mon Mar 23, 2009 11:18 pm
file_get_content is the function
LonelyProgrammer
Forum Contributor
Posts: 108 Joined: Sun Oct 12, 2003 7:10 am
Post
by LonelyProgrammer » Tue Mar 24, 2009 2:27 am
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();
?>