php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46574 Literal backslashes before other backslashes should also be escaped
Submitted: 2008-11-14 13:06 UTC Modified: 2008-11-14 15:10 UTC
From: francois at bonzon dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: BPJZ
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: francois at bonzon dot com
New email:
PHP Version: OS:

 

 [2008-11-14 13:06 UTC] francois at bonzon dot com
Description:
------------
http://www.php.net/manual/en/language.types.string.php#language.types.st
ring.syntax.single says:

"To specify a literal backslash before a single quote, or at the end of 
the string, double it (\\)."

This is incomplete, It should be added "before another backslash". Like 
this:

"To specify a literal backslash before a single quote, before another 
backslash, or at the end of the string, double it (\\)."






Reproduce code:
---------------
To echo a literal single-quoted string containing only two backslash characters, I start by writing the enclosing quotes and the two backslashes themselves:

echo '\\';

Then I should escape the second backslash, because it is "at the end of the string". It gives

echo '\\\';

The first backslash, according the documentation, should not escaped, because it is neither before a single quote or at the end of the string.

Expected result:
----------------
Two backslashes are echoed.

Actual result:
--------------
Parse error.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-14 15:10 UTC] sean@php.net
Duplicate of #44397
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 09:00:02 2026 UTC