Newline and Tab Characters
Escape characters are handy for introducing newlines (\n) and tabs (\t) within strings.
PHP
<?php $str = "Line 1\nLine 2\nLine 3\n" ; echo $str ; $str2 = "Name\tAge\tCity" ; echo $str2 ; ?> |
Output
Line 1 Line 2 Line 3 Name Age City
How to use Escape Characters in PHP ?
Escape characters in PHP are special characters that allow you to include non-printable characters, represent special characters, or format strings in a way that might be challenging with regular characters alone. They are preceded by a backslash \. In this article, we’ll explore how to use escape characters in PHP, covering various scenarios and providing detailed descriptions with examples.