quick intro

phemplate is simple and fast templating engine for php. it provides a way of substituting variables into text templates and do some dynamic block functionality including loops.

templating engines are meant for separation of presentation and logic. that means you can put all your HTML content outside of PHP scripts. HTML can be changed by designers without a fear of messing up your scripts.

don't be afraid and mail me your questions or bug reports. it will only make this code better.


  • move to sourceforge
  • i moved the project to sourceforge. i hope the site will also be migrated.
    i changed unit tests from PHPUnit to SimpleTest. current status.
  • v1.10.1
  • empty file warning bugfix. thanks kraupu.
  • v1.10
  • this version must be rock solid, because it's beta tested :)
  • two new features:
    • option TPL_STRIP_UTF_HEADER for set_file() will strip first 3 bytes of the file if it contains UTF header \xEF\xBB\xBF.

      usage example:
      set_file('temp', 'filename.html', TPL_STRIP_UTF_HEADER);
      set_file('temp', 'filename.html', TPL_STRIP_UTF_HEADER | TPL_BLOCK);

    • option TPL_OPTLOOP for process() will look for <opt> tags inside loop.

      usage example:
      process('out', 'block', TPL_OPTLOOP);
      process('out', 'block', TPL_OPTLOOP | TPL_NOLOOP);

  • updated unit tests and user guide.
  • v1.9.3
  • parse() bugfix. class was stripping characters after first }: 'a}b' -> 'a}'. now it does not :)
  • v1.9.2
  • 'remove_nonjs' bugfix.
  • v1.9!
  • variables can be tied with template: tie_var() and tie_loop().
  • error handler support. now you can catch error messages from template in your code.
  • custom block syntax, thanks to G. van den Hoven.
  • parse() works faster, thanks to Sergej Kurakin.
  • fixed remove_nonjs bug.
  • fixed set_root() bug.
  • documentation yet to come.
  • new website!
  • documentation will be online after a few days.
  • not a bug, but feature update!
  • process() now accepts parameters as bits.
  • v.1.8.1
  • almost a year without updates 8-O.
    on the other hand, i don't get much mails about phemplate usage.
    i stopped maintaining template benchmark, because it took too much time. also, my measures on production server show, that the biggest show-stopper is sql queries and template processing is performed in no time.
  • i hope we won't need bug update 1.8.1 :)
  • new tag <opt> !
  • v1.8
pukomuko, 2003