问题描述:

I have a database which delayes a lot to be loaded in xml, let's say the URL is www.mysite.com/my-database/, I need a PHP script that loads this URL and save a copy of the content after loading (it takes more than 120 seconds to load the database), and stores a copy of this in the root of my website, with the name db.xml. Thanks for help.

网友答案:

Iam sending the answer

Basically all you have to do is store the page info in a variable, then set the location and put the variable as the info to be saved to the location you set, so:

file_put_contents('/the-full-server-path/to-where/you-want-the-file-saved/file.ext',$the_variable_you_set_with_the_page_info);

If you can't figure out how to store the page info in a variable within the script creating the file you could just create a simple open/save file with PHP.

<?php

# This will open the actual xml page on your site with
# PHP and store the info in a variable. [Obviously you
# Have to change the location to the URL of the actual
# XML page people view.]

$the_variable_you_set_with_the_page_info=file_get_contents('http://www.yoursite.com/your-xml-file-to-save.xml');

 # Then you can save the file info where ever you would like.
 # For this one you'll have to find your server path which is
 # usually something like /home/public_html/the-directory-to-use

file_put_contents('/the-full-server-path/to-where/you-want-the-file-saved/file.ext',$the_variable_you_set_with_the_page_info);

 ?> 
相关阅读:
Top