Using Templates
Templates are shortcuts used to insert a pre-defined framework of code into your scripts. The purpose is to save time and reduce the potential for errors in standard, repetitive code units. Once a template is inserted, you can complete the code quickly using manual and automated code entry methods.
Requirements
A template must be defined in the Templates list in the Template Preferences page, accessed from Windows | Preferences | PHP | Editor | Templates, before it can be used. To learn how to create a new template from the Templates Preferences page, see Adding a New Template.
Note:
The i5 edition of Zend Studio includes pre-defined templates for using i5 PHP API Toolkit functions. See i5 Edition Extras for more information.
Templates are context sensitive and can be used in HTML, PHP, PHPDOC, JavaScript or CSS. The context of the current code being entered defines which templates are available. For example, PHP templates are not available if your current code is Java.
Inserting a Template into Code
This procedure describes how to insert a template into your script.
|
To insert a template:
|
|
|
|
Example: Entering "sw" and selecting the "switch statement" template from the list will give you the following code:
|
Note:
Templates can be created, imported and exported through the Template Preferences page, accessed from Window | Preferences | PHP | Editor | Templates.