purencool Posted November 22, 2010 Share Posted November 22, 2010 hi php freaks, Is there a way to parse an include file through the php engine and then place the contents into a variable? $x = include ($myfile); Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/ Share on other sites More sharing options...
jim_keller Posted November 22, 2010 Share Posted November 22, 2010 Use output buffering like this: <?php ob_start(); //start output buffer include('/path/to/myfile.php'); $contents = ob_get_clean(); //copy output buffer contents into $contents ?> Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/#findComment-1137747 Share on other sites More sharing options...
purencool Posted November 22, 2010 Author Share Posted November 22, 2010 thanks for the reply i get below is, Warning: include() [function.include]: http:// wrapper is disabled in the server configuration Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/#findComment-1137755 Share on other sites More sharing options...
purencool Posted November 22, 2010 Author Share Posted November 22, 2010 stupid me I wrote a complete path and the include function does not like it. It worked get thanks. Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/#findComment-1137757 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2010 Share Posted November 22, 2010 A URL is not a file system path. They are completely different things. Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/#findComment-1137759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.