You can reduce the number of keystrokes when you are typing PHP code by typing abbreviations to generate code from templates. The abbreviation is expanded into the template after you press the Tab key. Code templates also appear when you use code completion while editing PHP files.
The IDE comes with a set of code templates. You can also create your own code templates.
Below is the list of code templates that the IDE provides by default.
Abbreviation | Code Template | Expanded Text |
---|---|---|
cln | Clone | $$${NEW_VAR newVarName default="newObj"} = clone ${VARIABLE variableFromPreviousAssignment default="$variable"}; ${cursor} |
cls | Class | class ${ClassName} { function ${__construct}() { ${selection}${cursor} } } |
do | 'do' block | do { ${selection}${cursor} } while (${CONDITION variableFromPreviousAssignment instanceof="boolean" default="true"}); |
eco | echo | echo "${cursor}"; |
elseif | else-if block | elseif (${CONDITION variableFromPreviousAssignment instanceof="boolean" default="true"}) { ${selection}${cursor} } |
els | else block | else { ${selection}${cursor} } |
fcom | Folded comment | // <editor-fold defaultstate="collapsed" desc="${comment}"> ${selection}${cursor}// </editor-fold> |
fnc | function | function ${functionName}($$${param}) { ${selection}${cursor} } |
fore | foreach block | foreach (${ARRAY variableFromPreviousAssignment instanceof="array" default="$array"} as $$${value}) { ${selection}${cursor} } |
forek | foreach block with key | foreach (${ARRAY variableFromPreviousAssignment instanceof="array" default="$array"} as $$${key} => $$${value}) { ${selection}${cursor} } |
if | if block | if (${CONDITION variableFromPreviousAssignment instanceof="boolean" default="true"}) { ${selection}${cursor} } |
iface | interface | interface ${InterfaceName} { ${cursor} } |
inst | if...instanceof block | if (${VARIABLE variableFromPreviousAssignment default="$variable"} instanceof ${ClassName}) { ${selection}${cursor} } |
itdir | dir element iteration | $$${DIRH newVarName default="dirh"} = opendir(${$dirname}); if ($$${DIRH editable=false}) { while (($$${DIR_ELEM newVarName default="dirElement"} = readdir(${DIRH editable=false})) !== false) { ${selection}${cursor} } closedir($$${DIRH editable=false}); } |
iter | iteration | for ($$${IDX newVarName default="index"} = 0; $$${IDX editable=false} < count(${ARRAY variableFromPreviousAssignment instanceof="array" default="$array"}); $$${IDX editable=false}++) { ${selection}${cursor} } |
my_fa | mysql_fetch_array | while ($$${NEW_VAR newVarName default="row"} = mysql_fetch_array(${$query})) { ${selection}${cursor} } |
my_fo | mysql_fetch_object | while ($$${NEW_VAR newVarName default="row"} = mysql_fetch_object(${$query})) { ${selection}${cursor} } |
my_fr | mysql_fetch_row | while ($$${NEW_VAR newVarName default="row"} = mysql_fetch_row(${$query})) { ${selection}${cursor} } |
my_gc | ob_get_contents | ob_start(); ${selection}${cursor} $$${contents} = ob_get_contents(); ob_end_clean(); |
pclon | parent-clone | parent::__clone(); |
pcon | parent-construct | parent::__construct(); ${cursor} |
pr | print variable | print ${VARIABLE variableFromPreviousAssignment default="$variable"}; ${cursor} |
prln | print line | print ${VARIABLE variableFromPreviousAssignment default="$variable"}."\n"; ${cursor} |
prs | print "${cursor}"; | |
prv | print uneditable variable | print "\${VARIABLE variableFromPreviousAssignment default="$variable"} = ".${VARIABLE editable=false}."\n"; ${cursor} |
swi | switch | switch (${VARIABLE variableFromPreviousAssignment default="$variable"}) { case ${$value}: ${selection}${cursor} break; default: break; } |
thr | throw new | throw new ${Exception}; |
tryc | try...catch | try { ${selection}${cursor} } catch (${Exception} $$${exc}) { echo $$${exc editable=false}->getTraceAsString(); } |
vdoc | variable from comment | /* @var $$${VARIABLE variableFromNextAssignmentName default="variable"} ${VAR_TYPE variableFromNextAssignmentType default="ClassName"} */ |
while | while block | while (${CONDITION variableFromPreviousAssignment instanceof="boolean" default="true"}) { ${selection}${cursor} } |