[doc-en] master: Clarify when a backslash must be doubled in single-quoted strings (#6158)
| From: | Louis-Arnaud via GitHub | Date: | Thu, 26 Nov 2026 16:10:47 +0000 |
| Subject: | [doc-en] master: Clarify when a backslash must be doubled in single-quoted strings (#6158) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-24025@lists.php.net to get a copy of this message | ||
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-11-26T17:10:42+01:00
Commit: https://github.com/php/doc-en/commit/69b605f1304ddb32971cde8f4ded8c2fdcf14316
Raw diff: https://github.com/php/doc-en/commit/69b605f1304ddb32971cde8f4ded8c2fdcf14316.diff
Clarify when a backslash must be doubled in single-quoted strings (#6158)
* Clarify when a backslash must be doubled in single-quoted strings
* Mention doubling before another backslash, use simpara
Changed paths:
M language/types/string.xml
Diff:
diff --git a/language/types/string.xml b/language/types/string.xml
index b5bfbcab8f83..b57f6f637019 100644
--- a/language/types/string.xml
+++ b/language/types/string.xml
@@ -56,15 +56,16 @@
quotes (the character <literal>'</literal>).
</para>
- <para>
+ <simpara>
To specify a literal single quote, escape it with a backslash
- (<literal>\</literal>). To specify a literal backslash, double it
- (<literal>\\</literal>). All other instances of backslash will be treated
- as a literal backslash: this means that the other escape sequences you
- might be used to, such as <literal>\r</literal> or
<literal>\n</literal>,
- will be output literally as specified rather than having any special
- meaning.
- </para>
+ (<literal>\</literal>). A literal backslash can be specified by doubling
+ it (<literal>\\</literal>), which is required before a single quote,
+ before another backslash, or at the end of the string. All other instances
+ of backslash will be treated as a literal backslash: this means that the
+ other escape sequences you might be used to, such as <literal>\r</literal>
+ or <literal>\n</literal>, will be output literally as specified rather than
+ having any special meaning.
+ </simpara>
<note>
<simpara>
@@ -192,10 +193,10 @@ echo 'Variables do not $expand $either', PHP_EOL;
</tgroup>
</table>
- <para>
- As in single quoted <type>string</type>s, escaping any other character will
- result in the backslash being printed too.
- </para>
+ <simpara>
+ Escaping any other character will result in the backslash being printed
+ too.
+ </simpara>
<para>
The most important feature of double-quoted <type>string</type>s is the fact