Archive for the 'php' Category

10 lines implementation of PHP template engine

November 4th, 2007

PHP provides the following functions.

extract($array) — import associated array as local variables. include($filename) — read PHP file and evalue it.

Using these functions, you can get your own PHP template engine in 10 lines. The following is an example.

Why Smarty is too slow?

November 3rd, 2007

Smarty Template Engine is the most popular and widely used template engine for PHP. It is believed that Smarty is fast because it compiles templates into PHP code, but it is not true.

I have tried a simple benchmark program to measure speed of Smarty and PHP include() function. The result shows that PHP include() function is more [...]