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

前端 未结 13 746
无人共我
无人共我 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 05:07

    I prefer to use php heredoc function, this way I don't need to escape any characters, ex:

    
    
    
    
      
      
       
    
       $title 
    
     
     
     
     
    
     
     
    
     
     
     
     
    LOL;
    ?>
    

    Note:

    Heredoc text behaves just like a double-quoted string, without the double quotes. This means that quotes in a heredoc do not need to be escaped, but the escape codes listed above can still be used. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.

提交回复
热议问题