|
static | get_content ($url, $filename, $time_cache_second) |
| Check if the file exists, if yes then read otherwise take it from the url,. More...
|
|
Definition at line 35 of file file_cache.class.php.
◆ get_content()
static Noalyss\File_Cache::get_content |
( |
|
$url, |
|
|
|
$filename, |
|
|
|
$time_cache_second |
|
) |
| |
|
static |
Check if the file exists, if yes then read otherwise take it from the url,.
- Parameters
-
$url | url to the file to get the content |
$filename | fullpath to the filename of the cache |
$time_cache_second | valid time, if the cache is older , than reload it from the url |
- Returns
- void
Definition at line 44 of file file_cache.class.php.
45 {
47 if (file_exists($filename)) {
48 $date_time = new \DateTime();
49 $file_tmstamp = filemtime($filename);
50
51 $delta = $date_time->getTimestamp() - $file_tmstamp;
52
53
54 if (
$delta > $time_cache_second) {
56 $f_file = fopen($filename, "w+");
57 if ( $f_file == false ) {
59 }
61 fclose($f_file);
62 } else {
63 $content = file_get_contents($filename);
64 }
65 } else {
67 $f_file = fopen($filename, "w+");
68 if ( $f_file == false ) {
70 }
72 fclose($f_file);
73
74 }
76 }
References $content, $delta, and $url.
The documentation for this class was generated from the following file: