Skip to content

Instantly share code, notes, and snippets.

@KaiserWerk
Last active April 7, 2020 06:26
Show Gist options
  • Select an option

  • Save KaiserWerk/13bfd40e10e8c853d1febe024a635ba3 to your computer and use it in GitHub Desktop.

Select an option

Save KaiserWerk/13bfd40e10e8c853d1febe024a635ba3 to your computer and use it in GitHub Desktop.
Writing a PHP cache file using PHP
<?php
// reading data from any source
$array = call_procedure_here();
$output = '<?php' . PHP_EOL . '$myarray = ' . var_export($array, true) . ';' . PHP_EOL . '?>';
file_put_contents(__DIR__ . '/cache/cache_file.php', $output);
// include in other files
include __DIR__ . '/cache/cache_file.php';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment