0

我有一个在 xml 中加载延迟很多的数据库,假设 URL 是 www.mysite.com/my-database/,我需要一个 PHP 脚本来加载这个 URL 并在加载后保存内容的副本(它加载数据库需要 120 多秒),并将其副本存储在我网站的根目录中,名称为 db.xml。感谢帮助。

4

1 回答 1

0

我正在发送答案

基本上你所要做的就是将页面信息存储在一个变量中,然后设置位置并将变量作为要保存到你设置的位置的信息,所以:

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

如果您不知道如何将页面信息存储在创建文件的脚本中的变量中,您可以使用 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);

 ?> 
于 2013-09-11T20:03:00.960 回答