Phpstorm Live template plus php short syntax-Open tags to create native templates

Source: Internet
Author: User

About PHP should not use the template has been discussed, supported by the use of templates more concise, easy to communicate with front-end engineers. Against the saying that PHP itself supports inline syntax, there is no need to use a template to reduce performance.

In fact, the use of Php phrase method, direct embedding is not very ugly, the support of the loop what support, and then with the Phpstorm artifact live Template, even shift does not have to press, very convenient. (Other Ides should also have the appropriate code snippet functionality)

First look at the effect:

Output [stv]<?= $x? >//if-else [Stif]<? if ($x > $y):?> The switch is not a branch but a PHP block because it has to be followed by a break. But because the if-else in the phrase method is also very intuitive, can replace switch. I also specially added &lt in the Phpstorm; ElseIf ($x = = 1):?> fragments, convenient to increase the judgment logic.


The prerequisite is to open support in php.ini, Short_open_tag = on. Also supported by the SAE, other cloud sites have not yet been tried. In addition, after PHP5.4, do not set Short_open_tag=on, can also support <??> short syntax (except <?=?> still need to set php.ini to open), it shows that there is a lot of demand for it.


Here is the Phpstrom to add live template, this is equivalent to the syntax hint, you enter the first few letters (keywords), press TAB, it will automatically fill the custom.

I wrote the keyword in parentheses in the above code.

Phpstorm configuration I will not paste it all, back to need, the following is a while [STW] Example:

<? while ($$ $VAR $ $COND $ $COMP $):?> $END $<? $$ $VAR $++?> <? Endwhile?>

Setting.jar: Setting.jar (which only includes the live template settings and is placed in a self-built directory without worrying about overwriting your own settings.) )

Phpstorm Live template plus php short syntax-Open tags to create native templates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.