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); Quote 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 ?> Quote 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 Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/219413-parsing-include-file/#findComment-1137759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.