Pokud používáte automatické doplňování kódu v Eclipse (Zend Studiu) bude se Vám hodit následující tabulka šablon. Pokud nevíte jak ji použít, zkuste v editoru napsat například "cls" a stisknout "ctrl+space". Vlastní šablony si můžete přidat v nastavení: Window->Preferences->PHP->Editor->Templates.
| class | class statement |
|---|---|
class ${class_name} {
function ${function_name}() {
${cursor};
}
}
| |
| cln | Clone an object |
${dollar}${new_obj} = clone ${dollar}${variable};
${cursor} | |
| closure | lambda function statement (closure) |
function (${parameters}) use (${lexical_variables}) {
${cursor};
}
| |
| cls | class statement |
class ${class_name} {
function ${function_name}() {
${cursor};
}
}
| |
| eco | echo a string |
echo("${}");
${cursor} | |
| elif | elseif statement |
elseif (${condition}) {
${cursor};
}
| |
| els | else statement |
else {
${cursor};
}
| |
| fnc | function statement |
function ${function_name}() {
${cursor};
}
| |
| for | for statement |
for (${dollar}${index} = 0; ${dollar}${index} < ${number_variable}; ${dollar}${index}++) {
${line_selection}${cursor}
} | |
| fore | foreach statement |
foreach (${dollar}${array_expression} as ${dollar}${value}) {
${cursor};
}
| |
| forek | foreach with key statement |
foreach (${dollar}${array_expression} as ${dollar}${key} => ${dollar}${value}) {
${cursor};
}
| |
| function | function statement |
function ${function_name}() {
${cursor};
}
| |
| if | if statement |
if (${condition}) {
${cursor};
}
| |
| inst | instanceof statement |
if (${dollar}${variable} instanceof ${class}) {
${cursor};
}
| |
| itdir | iterates a directory |
${dollar}${dirh} = opendir(${dirname});
if (${dollar}${dirh}) {
while (${dollar}${dir_element} = readdir(${dollar}${dirh})) {
${cursor};
}
unset(${dollar}${dir_element});
closedir(${dollar}${dirh});
}
| |
| iter | iterates an array |
for (${dollar}${number_variable} = 0 ; ${dollar}${number_variable} < count(${dollar}${array_variable}) ; ${dollar}${number_variable}++) {
${cursor};
}
| |
| lambda | lambda function statement (closure) |
function (${parameters}) use (${lexical_variables}) {
${cursor};
}
| |
| my_fa | mysql_fetch_array() loop |
while (${dollar}${row} = mysql_fetch_array(${dollar}${query})) {
${cursor};
}
| |
| my_fo | mysql_fetch_object() loop |
while (${dollar}${row} = mysql_fetch_object(${dollar}${query})) {
${cursor};
}
| |
| my_fr | mysql_fetch_row() loop |
while (${dollar}${row} = mysql_fetch_row(${dollar}${query})) {
${cursor};
}
| |
| my_gc | Trap code output |
ob_start();
${cursor};
${dollar}${contents} = ob_get_contents();
ob_end_clean();
| |
| ns | namespace statement |
namespace ${name}; | |
| pclon | Call parent's clone |
parent::__clone(); | |
| pcon | Call parent constructor |
parent::__construct();
${cursor} | |
| pr | print an expression |
print ${};
${cursor} | |
| prc | prints the current class name |
print("${class_container}");
${cursor} | |
| prf | prints the current function name |
print("${function_container}");
${cursor} | |
| prln | print with new line |
print ${}."\n";
${cursor} | |
| prs | print a string |
print "${}";
${cursor} | |
| prv | print a value |
print("\${dollar}${variable} = ". ${dollar}${variable});
${cursor} | |
| swi | switch statement |
switch (${dollar}${variable}) {
case ${value}:
${cursor};
break;
default:
;
break;
}
| |
| try | try catch block |
try {
${cursor}
} catch (${Exception} ${dollar}e) {
}
| |
| use | use statement |
use ${namespace} as ${alias}; | |
| while | while loop |
while (${condition}) {
${cursor};
}
| |