2.2. Document generation

Now that we have introduced taglibs, two words need to be said about document generation.

When a tag is expanded it can output XHTML and/or PHP code. Therefore document generation is actually a two-step process: the starting point is a document containing tags and XHTML, this document is processed by the taglibs engine to produce a page that contains the XHTML from the original document and the result of tags expansion, which again is XHTML plus PHP code. The final XHTML/PHP page is evaluated as normal PHP script.

It's now clear that with respect to a traditional PHP script there is one more processing phase. Fortunately the taglibs engine is smart enough to cache documents after they have been processed: this means that taglibs processing only occurs once after the document has changed.