About PHP should not use the template has been discussed, supported by the use of templates more concise, easy to communicate with the front-end project division. The objection is that PHP itself supports inline syntax, and it is not necessary to use a template to reduce performance.
In fact, using PHP's phrase method. Direct embedding is also not very ugly, the support of the loop what support, and then with the Phpstorm artifact of the live Template, even shift does not have to press, very convenient. (Other Ides should also have the corresponding Code snippet feature)
First look at the effect:
output [Stv]<?= $x? >//if-else [Stif]<? if ($x > $y):?
>
>
><?
foreach ($list as $val): >a=<?= $val? ><? Endforeach >//foreach key=>value [stforek]<? foreach (Array (' A ' =>1, ' B ' + 2) as $key = $var): ><?= $ $key? >=><?= $var?
><? Endforeach?
>//while [Stw]<? while ($i <):?>
Switch is not a branch, but a PHP block, because it has to be followed by a break. Just because the if-else in the phrase method is also very intuitive, can replace switch. I also specially added < in the Phpstorm;? ElseIf ($x = = 1):?> Fragment for easy addition of inference logic.
The prerequisite is to open support in php.ini, Short_open_tag = on. Also supported in the SAE. Other cloud sites have not yet been tried.
Other than that. PHP5.4 after, do not set short_open_tag=on,<?=?> is always available, (but <?
?> still need to set php.ini to open). It shows that there is a lot of demand for it. Really worry about compatibility can manually change the live template, will <?> change to <?php?
>.
The following is the addition of the live template in Phpstrom, which is equivalent to the syntax hint, you enter the first few letters (keyword). Press TAB. It is on its own initiative to the definition of the complement.
Keyword I wrote them in brackets in the code above.
Phpstorm configuration I do not have to paste, the back of the need, the following is a demo example of while [STW]:
<? while ($$ $VAR $ $COND $ $COMP $):?> $END $<? $$ $VAR $++?> <? Endwhile?>
Setting.jar: Setting.jar (which contains only the live template settings.) And put it in a self-built folder. Don't worry about overwriting your own settings.
)
Phpstorm Live template plus php short syntax-Open tags to create native templates