Escape HTML to PHP or Use Echo? Which is better?

前端 未结 13 753
无人共我
无人共我 2020-12-01 04:34

In terms of performance , what would be better. Using PHP to echo all the HTML output so I can pepper it with the various bits of working code and variables or escape HTML t

13条回答
  •  佛祖请我去吃肉
    2020-12-01 04:54

    The latter is much more readable. It's also more easily editable (you do not have to escape quotes in HTML, for example). And it preserves whitespace without any hassle, which may be preferred, particularly for debugging purposes.

    I almost wish PHP would enable print() and echo() to automatically convert HTML characters so that people would stop using them to generate HTML.

提交回复
热议问题