Answer: Use the Newline Characters ' \n ' or ' \r\n ' You can use the PHP newline characters \n or \r\n to create a new line inside the source code. However, if you want the line breaks to be visible in the browser too, you can use the PHP nl2br() function which inserts HTML line breaks before all newlines in a string.
If you need to insert a Carriage Return in a string in PHP: Carriage return is: "\r" But carriage return (CR) is different from "new line" (NL) New Line (NL) is "\n" What in HTML is called "line break" is the sum of a CR and a NL.
Using Line Breaks as in HTML: The <br> tag in HTML is used to give the single line break. It is an empty tag, so it does not contain an end tag. Example: PHP.
So, for example, we could use the string EOT (end of text) for our delimiter, meaning that we can use double quotes and single quotes freely within the body of the text—the string only ends when we type EOT .
put it in double quotes
echo "\t";
See: http://php.net/language.types.string#language.types.string.syntax.double
"\n" = new line
'\n' = \n
"\t" = tab
'\t' = \t
"\t"
not '\t'
, php doesnt escape in single quotes
Put it in double quotes:
echo "\t";
Single quotes do not expand escaped characters.
Use the documentation when in doubt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With