Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make php display \t \n as tab and new line instead of characters [closed]

People also ask

How do you add a line break in PHP?

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.

What is carriage return in PHP?

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.

Does BR work in PHP?

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.

What is EOT in 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.