DamienRoche Posted February 27, 2009 Share Posted February 27, 2009 Not sure how to approach this. I want to be able to generate a php file. Can I simply include the php I want to include in the file, in a string/array? Are there any pitfalls to this? Thanks. Link to comment https://forums.phpfreaks.com/topic/147127-can-you-generate-a-file-and-include-php-within-it/ Share on other sites More sharing options...
Mchl Posted February 27, 2009 Share Posted February 27, 2009 If I understand correctly, yes it is possible. Show an example of what you're trying to achieve perhaps? Link to comment https://forums.phpfreaks.com/topic/147127-can-you-generate-a-file-and-include-php-within-it/#findComment-772484 Share on other sites More sharing options...
DamienRoche Posted February 27, 2009 Author Share Posted February 27, 2009 Ok, well if I say put this code into a string: <?php $var = "value"; ?> <html> <?php include('head.php');?> <?php include('body.php');?> <?php include('foot.php');?> </html> example: $string = "<?php $var = \"value\"; ?> <html> <?php include('head.php');?> <?php include('body.php');?> <?php include('foot.php');?> </html>"; #generate file here and save string into it. ...will it parse that if I put it into a php file?- or generate one with it? Maybe so, not had chance to test. My main concern is if anybody knows of any pitfalls with this. Will the code be parsed as php, simple as...or is there some other element that comes into play that may compromise it? Thanks. Link to comment https://forums.phpfreaks.com/topic/147127-can-you-generate-a-file-and-include-php-within-it/#findComment-772630 Share on other sites More sharing options...
Mchl Posted February 27, 2009 Share Posted February 27, 2009 This should work fine, as long as you take care of proper escaping all " quotes. Link to comment https://forums.phpfreaks.com/topic/147127-can-you-generate-a-file-and-include-php-within-it/#findComment-772786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.