is Short tag good practice in php?

前端 未结 4 510
长发绾君心
长发绾君心 2020-12-11 19:56

if I enable short tag = true, then I can use like below


Instead of



        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 20:48

    1. It not a good practice. Why i said like that because let say you want to push your code to production and you are using shared hosting. In PHP 5.4.0 above php short tags enabled by default. What if the shared hosting use the older PHP version. Some shared hosting you cannot override php.ini settings. If you want to use php shorttags you must enable it on php.ini. Refer the link below. The PHP short tag also can conflict with XML code .

      http://php.net/manual/en/ini.core.php#ini.short-open-tag

    2. No server dependency

    3. It totally not depend on framework.

提交回复
热议问题