开发者

No newlines in template file

So i am writing an open source software written in PHP and i am going to use a template system. The templates will be stored on the hard drive.

I tried this method, however 开发者_StackOverflow中文版all the html that is in the files gets displayed in just one line, while in the files itself it is on a few lines.

Why is that?


What's likely happened is that whatever you're viewing the source put it all on one line and ignored the linebreaks added in by whatever editor you use.

It could also be the editor you're using to edit the included file. There's actually several different ways of marking an end-of-line (see this Wikipedia article) but the two most common are Windows (\n\r) and *nix (\n). Check your file settings within your editor to see if it could be an issue. Most anything is compatible with both, but it's definitely worth taking a look. The *nix version is my personal choice, even those I'm a Windows user.


You can put all the \n in HTML you want, it won't do anything.

I suspect you're looking for <BR>


If all you're doing is including a plain text file and displaying it with php, then it's going to be interpreted as html, regardless of whether or not there's any tags in it. All whitespace in html is displayed as just a single space, so all your text is ending up on one line. 2 possible solutions: convert the line-endings in your text to html using nl2br() or force a content-type of plaint-text using header("Content-Type: plain/text");

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜