How to get pretty HTML source code from PHP generated output?

前端 未结 2 1971
说谎
说谎 2021-01-23 01:54

When you look at the source code of PHP generated output usually everything is on one line, it makes it very hard for front end developers to read the code and trouble shoot.

相关标签:
2条回答
  • 2021-01-23 02:36

    For more or less clean looking PHP generated code I used " signs for the echo output Strings, wich enables you to use \n and \t or other codes like that to make new Lines or Code indentation. If you need " signs in your output you need to escape them with \". this will output a " but PHP will treat it like a usual character.

    I know it is a pain getting a beautiful code this way but at least it makes it readable.

    0 讨论(0)
  • 2021-01-23 02:55

    You could use the tidy PECL extension - see this related question for examples.

    0 讨论(0)
提交回复
热议问题