I just got a simple thought about PHP function…
When you should use nl2br to make text line breaks:
- Before inserting data to db(MySQL).
- After, retrieving the data from db.
- Doesn’t matter.
I thought that using a PHP function like nl2br every time when retrieving the data from db will put more pressure to the server (CPU), or not?
Any transformation for the output medium (that includes any HTML escaping or converting newlines to HTML) should happen at the latest possible moment, preferably right as you’re outputing to the HTML page.
@Jeff_Mott is absolutely correct.
It may also be helpful to know that the
nl2br function doesn’t actually convert a newline character to a
<br>. It simply inserts the
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.