How can I echo HTML in PHP?

后端 未结 13 2554
耶瑟儿~
耶瑟儿~ 2020-11-22 06:40

I want to conditionally output HTML to generate a page, so what\'s the easiest way to echo multiline snippets of HTML in PHP 4+? Would I need to use a template framework lik

13条回答
  •  天命终不由人
    2020-11-22 07:13

    I am partial to this style:

      
        
    <%    if (X)
          {
    %>      Definitely X
    <%    }
          else
          {
    %>      Totally not X
    <%    }
    %>  
      
    

    I do use ASP-style tags, yes. The blending of PHP and HTML looks super-readable to my eyes. The trick is in getting the <% and %> markers just right.

提交回复
热议问题