File get contents

From TORI
Jump to: navigation, search

file_get_contents is php command used to get contents of a file or that of a side specified as argument.

Example

Here is sample of php code that downloads the content of the last Worldmeters report about coronavirus:


<?php
#date_default_timezone_set("Japan");
date_default_timezone_set("GMT");
for($n=0;$n<1400;$n++)
{
#$d=date("Y.m.d:H:i:s")."gmt.txt";
sleep(6*3600);
$d=date("m.d.H.i.s")."gmt.txt";
echo $d,"\n";
$f=file_get_contents("https://www.worldometers.info/coronavirus/");
file_put_contents($d,$f);
}
?>

References


Keywords

Coronavirus, file_get_contents, file_put_contents, Php, Worldometers