PHP Alternative Control Structures, any drawbacks?

后端 未结 5 1042
天涯浪人
天涯浪人 2021-01-21 02:14

I\'ve been working with PHP code that generates HTML without any templating, and it\'s quite spaghetti and difficult to read with the way they\'ve structured it. On

5条回答
  •  孤城傲影
    2021-01-21 02:51

    Is this portable?

    Yes

    Is this standard?

    Yes

    Is this slower in any significant way (I understand it takes more chars)

    I don't know.

    But imho it increases readability and maintainability very much if you use it in combination with HTML.

    Example:

    
        

    vs

    
        

    It is just a small example but I think endif and endforeach are much easier to spot as . So yes, definitely use it with HTML!

    I don't use it anywhere else though because in "normal" code I find it more difficult to read.

提交回复
热议问题