PHP Classes

File: test_01_hello_world.php

Recommend this page to a friend!
  Classes of n/a   Cache output and objects   test_01_hello_world.php   Download  
File: test_01_hello_world.php
Role: Example script
Content type: text/plain
Description: Hello World
Class: Cache output and objects
Cache the output of PHP scripts in files
Author: By
Last change:
Date: 17 years ago
Size: 941 bytes
 

Contents

Class file image Download
<?

/*

$cache is object used to cache output and objects.

Cache constructor arguments are:

  $path:
    - Location where cache files will be stored
   
  $disable=false
    - Disable caching (for debugning purpuoses etc.)
   
  $disable_output
    - Disable output of cached data
    - Data can still be accessed using $cache->output variable
   
*/

require_once("cache.php");

$path = ".";
$file = "cache.test_01.tmp";
$expire = 20;

$cache = new Cache($path);

// Part in side of while loop is cached to $file

while($cache->save("cache.test_01.tmp",$expire))
{
    echo(
"<b>Hello World!</b><br>");
    echo(
"In cached part it's ".date("H:i:s")."<br>");
    echo(
"<i>This part will expire in ".$expire." s</i><br>");
    echo(
"Output is stored in <b>".$path."/".$file."</b><br>");
    echo(
"<br>");
}

echo(
"<b>This part is executed every time</b><br>");
echo(
"Real time is ".date("H:i:s")."<br>");
   

?>