Dreamweaver MX has two capabilities that make working with PHP more productive: Tag Chooser Code Snippets The Tag Chooser Dreamweaver MX's Tag Chooser can help you insert well-formed PHP tags in your documents. You can access the Tag Chooser by clicking the Tag Chooser button on the toolbar or by right-clicking inside your Dreamweaver document and choosing Insert Tag from the pop-up menu. When the Tag Chooser is open, double-click the PHP folder. You have two choices: expressions and scriptlets. If you select expression, the Tag Chooser inserts the following PHP code into your document: <?php echo ?> If you select scriptlet, the Tag Chooser inserts the following PHP code into your document: <?php ?> You can then insert your code in between the start and end tags. Figure 24.2. Using the Tag Chooser to select a PHP expression. Saving Code Snippets Dreamweaver MX allows you to save any content, HTML markup, or PHP code as code snippets that you store in the Snippets library. To save a piece of PHP code as a snippet, follow these directions: -
Highlight the PHP code you want to save as a snippet. -
Click the Snippets tab under Code in the right pane. -
Click the Create New Folder icon. -
Name the new folder PHP Snippets. -
Double-click the folder to open it. -
Click the Create New Snippet icon. -
In the Snippet dialog box, give your snippet a name that's descriptive of the code. -
Optionally, provide a description of the code. -
Choose Insert Block (this works for most PHP code blocks) instead of Wrap Selection. NOTE Wrap Selection is used to wrap code before and after any selection you've highlighted with the mouse. It's a handy way to wrap <b> and </b> tags around a word you've highlighted, but it isn't very useful when you're inserting PHP code. -
Choose Code as the Preview Type. -
Click OK to close the dialog box. To use a code snippet, click where you want the Snippet to go and then double-click it from the list of snippets. Dreamweaver MX inserts the snippet into your document. Figure 24.3. Use the Code Snippet feature to save frequently used PHP code. |