2013-01-23 41 views
0

我有如下的PHP代碼的HTML代碼:複製從URL到其他文件中使用PHP

<?php 
    $htmlFile = file_get_contents(http://archi-graphi.com/arcancianev/sejour-29-eau_turquoise_en_corse.html'); 
    $pdfHtml = ('pdfFile.html'); 
    copy($htmlFile, $pdfHtml); 
     // Now you can choose to run a check to see if the new copy exists, 
     // or you have the option to do nothing and assume it is made 
     if (file_exists($pdfHtml)) { 
      echo "Success : has been made"; 
     } else { 
      echo "Failure: does not exist"; 
     } 
?> 

但我得到了錯誤的信息Warning: copy(<!DOCTYPE html> <html lang="fr"> <head> <meta charset="utf-8" /> <title>Vacances Arcanciane</title> ...我不知道什麼是錯誤from.Anyone幫我請,謝謝。

回答

3

糾正我,如果我錯了,但你可能尋找的file_put_contents代替copy

<?php 
    $html = file_get_contents('http://archi-graphi.com/arcancianev/sejour-29-eau_turquoise_en_corse.html'); 
    $pdfHtml = 'pdfFile.html'; 

    // this is probably what you're trying to do 
    file_put_contents($pdfHtml, $html); 

     // Now you can choose to run a check to see if the new copy exists, 
     // or you have the option to do nothing and assume it is made 
     if (file_exists($pdfHtml)) { 
      echo "Success : has been made"; 
     } else { 
      echo "Failure: does not exist"; 
     } 
?> 
相關問題