Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
From the author of Vastly Improved PHP Code Hinting

Vastly Improved PHP Code Hinting

Dreamweaver has always had strong support for coders, mainly through the provision of code hints. Perhaps one of Dreamweaver's best-kept secrets was that pressing Control-spacebar in a PHP code block gave access to a huge number of PHP core functions—Dreamweaver CS4 had support for more than 2,500.

The keyboard shortcut remains the same in Dreamweaver CS5, but now it gives you access to much more. PHP code hints now cover all core functions, classes, and constants. When you select a function or class, a panel appears automatically and displays the relevant page from the official PHP documentation, complete with examples of how to use the code. Need more information? Click the link to the same page in the online documentation, where you can explore the PHP manual in greater depth.

Code hinting doesn't end there. Dreamweaver CS5 now supports code introspection—it scans your files and builds code hints on the fly for all custom functions and classes. This action happens automatically when the definition file is linked directly to the current page, but the site-specific code hints feature also lets you specify other files and folders to scan. This option is particularly important for working with a third-party library or CMS that loads definition files dynamically only when they're needed. Dreamweaver CS5 automatically recognizes Drupal, Joomla!, and WordPress, so setting up site-specific code hints for one of these systems takes only a couple of seconds. Defining the settings for a third-party library, such as the Zend Framework, takes a little longer, but you can apply the same settings to any site within Dreamweaver. Developing your own pages and themes for a CMS becomes much easier, giving you access to all the custom functions, and ensuring that you spell them correctly and use the right syntax.

A couple of my favorite thoughtful touches in the improved code hints might easily go unnoticed:

  • The underscore is so widely used in function and class names that Dreamweaver CS5 lets you omit it when typing.
  • Moreover, Dreamweaver constantly scans all code hints, looking for matching patterns that are not case-sensitive. For example, if you type image after activating code hints, you get not only all functions that begin with image, but also exif_imagetype() and getimagesize().

Because you now can leave out underscores and search for any substring, you can devise your own keyboard shortcuts for commonly used classes and functions. For example, if you've set up site-specific code hints for the Zend Framework, you might type this:

new fera

Bingo! Dreamweaver CS5 identifies the fer of Transfer followed by the a of Adapter to select this:

Zend_File_Transfer_Adapter_Http

Just press Enter/Return, and the whole class name is inserted into your code, complete with the correct capitalization and underscores.

  • + Share This
  • 🔖 Save To Your Account