pizzaguy Posted July 3, 2009 Share Posted July 3, 2009 Is there anyway to have a PHP file "pretend" to be written to, but instead process what was supposed to be written to is as input? Basically, if I use fwrite to write "hello world" to "test.php", I want "test.php" to take "hello world" as variable input, instead of actually having "hello world" written into the file; is that possible? Link to comment Share on other sites More sharing options...
Ingolme Posted July 3, 2009 Share Posted July 3, 2009 You can just directly write PHP code to a file. But what you're asking doesn't make much sense, there are likely many more efficient ways to do whatever you're trying to do. Can you explain why you want to write in a file expecting it to be stored in a variable? Link to comment Share on other sites More sharing options...
pizzaguy Posted July 3, 2009 Author Share Posted July 3, 2009 its basically laziness. I have a plugin for my wordpress blog. It takes all the posts and writes them to a sitemap.xml file (the file can be user specified). I wanted change it to have the data written to a database, and then have a php file write it when called. I figured the easiest way would be to do what I am saying above. Change the setting to have it write to sitemap.php, but instead of writing to the file, sitemap.php would take the information and write it to a database... Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2009 Share Posted July 3, 2009 It would be easiest to modify Wordpress to write to a database instead of a file, and change sitemap.php to read from the database. You would just need to find and change the code that creates the sitemap. You can't "intercept" fwrite and make it do something else like that. You would need to change the code for the fwrite function in order to do that. That's beside the issue though - when they use fopen it immediately deletes the contents of the file. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.