开发者

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

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.

So is there a way to get PHP generated output to go from this:

<ul><li>Hello</li><li>Hola</li><li>Bonjour</li></ul>

to

<ul>
    <li>H开发者_如何学Goello</li>
    <li>Hola</li>
    <li>Bonjour</li>
</ul>

WITHOUT using /n line breaks all over the server side code which just makes that messy.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜