I have the following code below, and I want to save that xml file on disk, how can I do this?
<?php
// CAPTURE THE BUFFERED OUTPUT AND WRITE A FILE
$rss = ob_get_clean();
file_put_contents('my_rss.xml', $rss);
?>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
file_put_contents() writes directly to a file. That means your file is “saved” when you use this function. Also, if the file name does not exist, it is created.
This being said, the first parameter of the function should be the path to your file. Right now, it is simply going to save my_rss.xml in the same directory as your php file.
If the file is not getting created, you probably have a permission problem or something. Make sure you have php errors turned on to see that.