Remove all the line breaks from the html source

前端 未结 9 2043
情书的邮戳
情书的邮戳 2020-11-27 04:50

Well I know obfuscation is a bad idea. But I want all of my html code to come in one long single line. All the html tags are generated through PHP, so I think its possible.

9条回答
  •  鱼传尺愫
    2020-11-27 05:17

    You can do :

    $output = '

    '. '

    Hello
    '. '

    ';

    This way, $output won't contain any line jump.

    This should also work :

    $output = preg_replace(array('/\r/', '/\n/'), '', $output);
    

提交回复
热议问题