# Quick Start ## Basics - [Download](http://phptal.org/download.html) latest version - Unpack it in your project or includes directory - Create PHP and template files - `index.php`: ``` php who_to_greet = "World"; // execute() returns result of template echo $phptal->execute(); ``` - `hello.xhtml`: ``` xml

Hello !

``` ## Gathering of data This is not a requirement, but good advice: avoid passing PHPTAL object (or template abstraction wrapper) around your entire program. MVC programs should be independent of their views (mental exercise: would your application break if there was no view?). Instead of setting variables directly on PHPTAL object, make your methods *return* all required information. You can also pass helper objects to PHPTAL which will load data on demand. ``` php $v) $phptal->set($k,$v); ``` ## Layout template `` is an invisible element you can use anywhere. It's useful when you want some TAL functionality, but don't want to litter markup with unnecessary `
` or ``. [METAL](http://phptal.org/manual/en/#metal) macros can be used to execute code from other templates. Conceptually macros are very similar to PHP functions: | | | | ----------------------------------- | ---------------------------------------------------------------------------------------------- | | `function name() {…}` | `
` | | `name();` | `
` | | `function name($argument_name) {…}` | `
` | | `name("argument data");` | `
argument data
` |`main.xhtml`: ``` xml \\ \\ <tal:block metal:define-slot="other-stuff-in-head"/> </head> <body> <div id="main"><tal:block metal:define-slot="maincontent"/></div>\\ </body> </html> ``` `subpage.xhtml`: ``` xml <tal:block metal:use-macro="main.xhtml/layout" tal:define="title 'title of the page'"> <p metal:fill-slot="maincontent">Hello world</p> </tal:block> ``` Note that the code didn't use `metal:*-slot` to set title of the page. Macros "see" variables [defined](http://phptal.org/manual/en/split/tal-define.html) in templates that call them, so simple values can be easily passed using variables. You don't have to fill all slots. Here `main.xhtml` defines `other-stuff-in-head` slot, which you could use e.g. for adding JavaScript or link to CSS, but you don't have to.