askbapi Posted April 9, 2009 Share Posted April 9, 2009 I want to create a PHP file in runtime. That mean a php script(a.php) will create another php file (b.php) and php file (b.php) can also run later. Php file (b.php) should have php code. Can it be done? If yes, Pls say how! Link to comment https://forums.phpfreaks.com/topic/153330-solved-create-php-file-in-runtime/ Share on other sites More sharing options...
Maq Posted April 9, 2009 Share Posted April 9, 2009 You would need to use fopen and fwrite. Link to comment https://forums.phpfreaks.com/topic/153330-solved-create-php-file-in-runtime/#findComment-805548 Share on other sites More sharing options...
askbapi Posted April 9, 2009 Author Share Posted April 9, 2009 fwrite() and fopen() both work fine while writing simple text. BUT how can i WRITE php code in the created file. For example : >I have created php file with fwrite. >Now i want to write code like this "include_once($ram."db.php")" in to the file. Link to comment https://forums.phpfreaks.com/topic/153330-solved-create-php-file-in-runtime/#findComment-805564 Share on other sites More sharing options...
daniel244rock Posted April 9, 2009 Share Posted April 9, 2009 $createfile = "newfile.php"; $fh = fopen($createfile, 'w'); fwrite($fh, "<?PHP \n include_once(\$ram.\"db.php\")\n ?>"); I think that should work to write that file you were wanting. Lemme check it though. alright, now it works fine. Link to comment https://forums.phpfreaks.com/topic/153330-solved-create-php-file-in-runtime/#findComment-805578 Share on other sites More sharing options...
askbapi Posted April 10, 2009 Author Share Posted April 10, 2009 Thank you, My problem is solved! Link to comment https://forums.phpfreaks.com/topic/153330-solved-create-php-file-in-runtime/#findComment-806290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.