doqrjrc95405 2015-06-19 18:54
浏览 22
已采纳

树枝与操作员相同

When comparing in PHP, it is advisable to use === instead of == due to intransitive nature and quirks like "5 is not a number" == 5.

By that guideline, does it mean that the same as operator should be used instead of == in Twig?:

{# "Wrong" #}
{% if foo.bar == 3 %}

{# Better #}
{% if foo.bar is same as(3) %}

And likewise for is not same as versus !=.

  • 写回答

1条回答 默认 最新

  • doufang1954 2015-06-20 11:31
    关注

    It makes sense when treating PHP and Twig as two very different tools. Fabien Potencier's main motive for creating Twig was to provide a tool for Web Designers, not Web Developers. (See his blog post for more insight).

    Web developers should know to be more explicit and use === as often as possible. In the realm of web design this is perhaps not as vital, but if needed, that feature is available as same as() in Twig.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入