0

我的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> ...,我不知道是什么错误。请任何人帮助我,谢谢。

4

2 回答 2

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";
        }
?>
于 2013-01-23T03:03:59.423 回答
-1

检查副本的变量顺序。它应该copy($pdfHtml, $htmlFile);代替copy($htmlFile, $pdfHtml);

于 2020-04-24T15:43:26.300 回答