How to Create a Line Break in PHP

PHP


In this article, we show how to create a line break in PHP.

Many times when writing PHP code, you may need to add a line break to space out PHP lines appropriately.

To create a line break in PHP, you use the line:

This line creates a line break so that any new information that is entered appears on the next line.

With data on the line, a concatenation operator (.) must be used with the br tag in double quotes, not single quotes. If placed in single quotes, the PHP echo statement will display the output, just as is. If placed in double quotes, the PHP echo function will process what is inside of the quotes, meaning the br tag and create a line break. The difference between single and double quotes in PHP is that, with single quotes, the PHP echo command passes functions, exactly as is, and with double quotes, the information, variables, HTML commands, etc, gets processed. An example is shown below:


This statement above will create a line break so that the next statement you write will start on a new line.

Example

These students are going on the trip:1)Sarah 2)Bill 3)Ryan

You can see in this example how everything is jumbled on one line. It would be much better put on separate lines.

Below are the statements with line breaks:

These students are going on the trip:
1)Sarah
2)Bill
3)Ryan


PHP Code

The PHP Code to create the above code is:



HTML Comment Box is loading comments...