PHP templates improved
By Tomas Mysik on Oct 16, 2009
Today, I would like to show you the latest improvements in PHP templates area.
The first improvement is that one can easily surround his/her code with these PHP statements:
- if / elseif
- try & catch
- ob_start & ob_end_clean
How to do that? Very easily, just select the code you want to surround and click a yellow bulb in the left side of the editor (or use ALT + ENTER).
Another improvement is that NetBeans tries to find a suitable variable during template generating - on the next image, where we just surrounded our code from the previous example with if (true) PHP template, one can see that "correct" variable has been used as a condition (variable $a in our case because it is a boolean). Also, please notice that the condition is preselected so it can be easily changed if needed (after you are done, just press ENTER and the cursor will be placed in the correct location, just after "$b = 10;" in our case).
Another possibility to insert a PHP template is to type its abbreviation (e.g. "if" for if statement) followed by TAB key.
The next example not only shows an improvement in PHP templates but also in PHP editor - first, we invoke PHP template for foreach statement by typing "foreach" and invoking code completion (CTRL + SPACE). You can see that its abbreviation is "fore".
The template is generated and as an array, proper variable is used ($arr in our case). And because PHP editor is really smart, the correct methods for $value variable can be offered.