Single Quoted Strings
Escape characters behave differently in single-quoted strings compared to double-quoted strings. In single-quoted strings, only the backslash itself (\\) and the single quote (\’) need to be escaped.
PHP
<?php $str = 'This is a single quote: \'' ; echo $str ; ?> |
Output
This is a single quote: '
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.