PHP coding tips

Posted by HTML-Kit Support August 16, 2012

If you're a PHP developer, you may appreciate many features that are built into HTML-Kit Tools. Features like PHP colorizers in light and dark color themes, selection matching for quickly finding variables, full screen editing for viewing more of your PHP code in a clutter-free display, instant search, brace highlighting, code folding, and many more.

HTML-Kit Tools has even more support for PHP than what you see in the default installation. As you know, PHP has a rich library of thousands of functions and support for them is available through optional HTML-Kit plugins.

Installing optional PHP plugins

So to get started, select "Tools > Plugin types > HTML plugins > Get plugins" from HTML-Kit Tools main menu and click "Browse A-Z" tab. The plugins page that opens up has a list of 100+ categories of PHP functions:


Install the plugins you're most likely to use. In this example, we'll install hkPHPFunctions_Strings plugin.

PHP menus on Actions Bar

Once installed, you'll get a PHP Strings button on the Actions Bar (Channel 2) with a drop-down menu:


PHP function dialogs

Each item on the menu brings up a dialog (sometimes called a wizard) for constructing and inserting the selected function:


Docked windows

Drop-down menus are great for displaying a reasonable number of items but of course some PHP libraries have dozens of functions. hkPHPFunctions_Strings plugin alone has 80+ PHP string functions. To make it easier to browse them, you can dock the list as a side window.

If you click the "Strings" button (instead of opening the long menu) on "Actions Bar > Channel 2 > PHP" tab, you'll get a window like this:


You get function dialogs here as well, and the window itself can be auto hidden when not in use. If you install multiple PHP function categories, you'll be able to have all or some of them open as docked windows.

PHP function name reminder

If you forget the exact name of a PHP function, type the first few characters or even just the first letter of a function, and press Ctrl+Space to get a list of matches:


Reusing variable names

You may have already used selection matching feature to find PHP variables and other code. But did you know that you can also get a list of variables in the current document and quickly insert them by typing '$' + letter ($var for example) and pressing Ctrl+Shift+J :


List of variables and function names

When you're editing a large PHP file with many variables, classes and function names, it may be more useful to have a docked window that list them all. "View > Document information > Code Navigator" gets you exactly that. You can then simply click a variable name or a function name to quickly jump to it in the editor.


Keeping TO-DOs and other notes

Instead of writing down to-do items in a separate file or a piece of paper, you can keep quick notes in PHP files. These notes can then be viewed and referenced in "Code Comments" window ("View > Document information > Code Comments" menu option) each time you open a given PHP file.


File versioning

If you ever need to go back to a previous version of a script, or just need to see what changes were made on a given date, open the script in question and select "File > Restore > Previous version" from the main menu. HTML-Kit Tools comes with easy-to-use file versioning feature that you can use to browse through previous versions of files.



ksPHPShorthandCtrlStructures is an excellent plugin written by Kay that makes great use of HTML-Kit Tools Shorthand feature. After installing ksPHPShorthandCtrlStructures, try this: type "switch" (without quotes) and press Ctrl+J shortcut. The areas highlighted in green are points in code that you can easily edit and jump to, using Tab and Shift+Tab keys.

I'll let you discover what happens but also try moving to the end of the last "case" and pressing Ctrl+J again!


So in the interest of not turning this blog post into a short novel, let me end the list of PHP-related features here. Please feel free to drop a note on the support forum if you have further questions or if I've failed to mention a feature that you've found useful.

comments powered by Disqus