947740 Posted June 23, 2009 Share Posted June 23, 2009 Basically, I want to set a variable equal to the HTML output of a PHP file. file_get_contents() does not work, because it tries to read the entire file. Is there a good way to do this? Link to comment https://forums.phpfreaks.com/topic/163366-getting-html-out-of-php/ Share on other sites More sharing options...
flyhoney Posted June 23, 2009 Share Posted June 23, 2009 You can probably do this, but I wouldn't recommend it: <?php ob_start(); include('some_file.php'); $output = ob_get_contents(); ob_end_clean(); echo $output; ?> Link to comment https://forums.phpfreaks.com/topic/163366-getting-html-out-of-php/#findComment-861983 Share on other sites More sharing options...
947740 Posted June 23, 2009 Author Share Posted June 23, 2009 And, why wouldn't you recommend it? Link to comment https://forums.phpfreaks.com/topic/163366-getting-html-out-of-php/#findComment-861984 Share on other sites More sharing options...
flyhoney Posted June 23, 2009 Share Posted June 23, 2009 I have no clue what is in "some_file.php". Including it like that _might_ work, but it will clutter up your namespace with whatever code is in "some_file.php". Try it, maybe it will work just fine Link to comment https://forums.phpfreaks.com/topic/163366-getting-html-out-of-php/#findComment-862008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.