- One of the basic tenets of any craft, whether it's building a cabinet or building a website, is to choose the right application for the job, and to do that, you need to know the requirements for the job. In this lesson, we'll take a look at the core necessities for PHP coding. It almost goes without saying, but I'll say it anyway, in the interest of completeness. A PHP Editor is, at its core, a plain text editor that has to be able to read and write PHP-compatible files, and what makes a plain text file compatible is the extension, which, depending on the version you're working with, could be anything from the generic .php to .php3, 4, 5, even .phps.
Beyond this absolutely bottom line requirement, everything is, as they say in the Deep South, gravy. However, it's gravy that not only makes the work more appealing but allows the more difficult recipes, if you will, to go down much smoother. So, what else is vital for any PHP Editor? I'd say that one of the top requirements is some sort of specific syntax handling, preferably a combination of color and formatting.
Now this is a multi-purpose feature. It differentiates between PHP code blocks and other surrounding code in an HTML/PHP hybrid page, as well as highlighting properties, methods, and functions. Not only do you want to be able to identify the key code elements at a glance, but you also want some help in coding them. PHP is a relatively robust, complex language, originally developed over 20 years ago, and over that time, it's been updated frequently and is currently on its 5th major version.
There are now well over 700 core PHP functions, almost 40 operators, and numerous logic constructs, like if/then, while, and for loops. That's a lot of functionality to keep track of. Code hinting is one way that can help you keep all of this PHP straight. A good code hinting system looks at what you're typing and quickly offers a list of suggestions that narrows with each keystroke.
The code hints are often displayed in a popup list, next to the current cursor placement, and the list is easily navigable by arrow keys. Once you've selected a function, the hinting can continue with a display of the function's syntax and any available attributes. Now that you've written out your PHP code, it's great to be able to verify any typos and other syntactical errors that could have crept in. Syntax checking is pretty much a must have as a baseline debugging effort that verifies your code can be parsed.