When you use PHP to create a web application, there are several layers:
- Your PHP code that outputs some data in
- a web server that transmits data over the network to
- A web browser that analyzes data and displays it on the screen.
Note that in the above example, this is just data that is transmitted together. In your case, this data is HTML, but it can be just plain text or even a PNG image. (This is one of the reasons you send the Content-Type: header to indicate the format of your data.)
Because it is so often used for HTML, PHP has many HTML-specific functions, but this is not the only format it can output. Thus, although the newline character is not always useful for HTML, it is useful:
- if you want to format the generated HTML code, not for a web browser, but for another person who can read,
- if you want to create plain text or another format in which newlines are important.
benzado
source share