PHP Classes

File: smarty/test_06_smarty.tpl

Recommend this page to a friend!
  Classes of n/a  >  Cache output and objects  >  smarty/test_06_smarty.tpl  >  Download  
File: smarty/test_06_smarty.tpl
Role: Auxiliary data
Content type: text/plain
Description: Templage for smarty plugin example
Class: Cache output and objects
Cache the output of PHP scripts in files
Author: By
Last change:
Date: 15 years ago
Size: 1,324 bytes


Class file image Download
<i>Smarty plugin test</i><br><br>

{cache file="cache.smarty_example.tmp" time="20"}
	<b>Hello Smarty!</b><br>
	In cached part it's {$date}<br>
	<i>This part will expire in 20 s</i><br>
	Output is stored in <b>./cache.test_01.tmp</b><br><br>
		function microtime_float()
		   list($usec, $sec) = explode(" ", microtime());
		   return ((float)$usec + (float)$sec);
		function bcpi($precision=30){
		        $accuracy = ($precision+5)*45/32;
			//accuracy worked till the 180th $precision, almost used 30 second to calculate
			    $n = 1;
			    $bcatan1 = 0;
			    $bcatan2 = 0;
			    while($n < $accuracy){
			//atan functions
			        $bcatan1 = bcadd($bcatan1, bcmul(bcdiv(pow(-1, $n+1), $n * 2 - 1), bcpow(0.2, $n * 2 -1)));
			        $bcatan2 = bcadd($bcatan2, bcmul(bcdiv(pow(-1, $n+1), $n * 2 - 1), bcpow(bcdiv(1,239), $n * 2 -1)));
		    return  bcmul(4,bcsub(bcmul(4, $bcatan1),$bcatan2),5);
		$time = microtime_float();
		$pi = bcpi(40);
		echo("<b>pi = ".$pi."</b><br><br>");
		echo("<b>This part is executed every 10 seconds</b><br>");
		echo("<b>Time of execution: <u>".(microtime_float() - $time)." s</u></b><br><br>");


<b>This part is executed every time</b><br>
Real time is {$date}<br>
For more information send a message to info at phpclasses dot org.