65.9K
CodeProject is changing. Read more.
Home

Caching Output in PHP

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.43/5 (3 votes)

Mar 30, 2010

CPOL
viewsIcon

6970

You should not define the object identifyer at the top of each page (because then you have to write out the same bit of code each time u want to access a object within a class.- (Insted Use a included class)Cachecache_class.phpExample Classclass Cache {function...

You should not define the object identifyer at the top of each page (because then you have to write out the same bit of code each time u want to access a object within a class. - (Insted Use a included class) Cache cache_class.php Example Class
class Cache {
function cache_start(){
// Start Cache CODE
}

function cache_end(){
// End Cache Code
}

}
At the bottom of the class we will need to add the object identifyer, this is a much better way of using objects within our class because rather then defining object identifyers all the time we can just define one identifyer. Once we include the file which contains our php cache class we can then use the functions which we have just created to enable cache.
$cache = new Cache();
Using Objects Within The Class
include('includes/cache.php');

$cache->start();

$chache->end();