/    Sign up×
Community /Pin to ProfileBookmark

Newlines, or not?

Kind of a dumb question, but are there pros & cons to sticking newlines (n) at the end of all the various outputs from php? I have pages where the vast majority of the html is spit out from php, and is on one enormously long line of code. Yes, I’m saving a few characters in the file size, but is there anything I’m missing? I see a lot of php examples given where a newline is spit out at the end of every echo.

Dave

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJul 16.2009 — If you are talking about when PHP is used to generate HTML source code, it just makes it more readable. For other applications such as writing to files it is more important obviously.
Copy linkTweet thisAlerts:
@tracknutauthorJul 16.2009 — Yes, for HTML output, sorry. So other than making my HTML more human-readable, no other advantages? There isn't going to be some server limit on a line length, or a performance reason to do it one way over the other?

Dave
Copy linkTweet thisAlerts:
@MindzaiJul 16.2009 — The newline character is just a character like any other, the server knows nothing about line lengths or anything else - when an HTTP response is sent by the server, the actual source code is just sent as a big long string of characters - this could be 1000 random characters or 1000 newline characters, it makes no difference.
Copy linkTweet thisAlerts:
@tracknutauthorJul 16.2009 — Cool, thanks much.

Dave
×

Success!

Help @tracknut spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...