Some usefull PHP code for slow CMS' without TPL System And/Or Cache
PHP Code:
<?php
class WhiteSpaceStripperAndSpeedTest
{
function __construct()
{
define('STARTTIME', microtime(true));
ob_start();
}
function __destruct()
{
$content = ob_get_contents();
ob_end_clean();
echo preg_replace('/\s\s+/', ' ', $content),"\n<!-- Loaded ",intval(substr((microtime(true) - STARTTIME) / 100, 2, 5))," milliseconds -->";
}
}
$whitespacespeedtest = new WhiteSpaceStripperAndSpeedTest();
?>
What this code does:
- It defines the starting time
- It saves the whole content in an object and makes the content empty
- It filters all unneeded whitespace to make the content smaller
- It outputs the content and says the time in milliseconds it took to load the page (Will bug after 10sec)
If you use this code don't give credits to me but to Monsma (because I made it for his CMS)
----
I'm just going to release some snippets of PHP I code sometimes just to make people get interests in PHP instead of flaming each other.
Re: Some usefull PHP code for slow CMS' without TPL System And/Or Cache
I'm sure FrostCMS 2.0 Final release is going to be awesome! Thanks azaidi :)