php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31804 Problem with \ in single quotes ('abc\')
Submitted: 2005-02-02 04:37 UTC Modified: 2005-02-02 08:40 UTC
From: neo_in_matrix at msn dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: Irrelevant OS: Windows, Fedora Core 1 & 3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: neo_in_matrix at msn dot com
New email:
PHP Version: OS:

 

 [2005-02-02 04:37 UTC] neo_in_matrix at msn dot com
Description:
------------
It seems there is a small problem with the \ char in single quotes.

I think the char \ is *not* an escape char in single quotes, as

echo 'abc\x';

outputs

abc\x

But, the following code

echo 'abc\';

gives an error:

PHP Parse error:  syntax error, unexpected T_STRING, expecting ',' or ';' in x:\test.php on line 1

However, the code
echo 'abc\\';

has no runtime error and it outputs

abc\

but it should output (with two \ chars)

abc\\


Reproduce code:
---------------
echo 'abc\x';
echo 'abc\\';
echo 'abc\';


Expected result:
----------------
abc\x
abc\\
abc\

Actual result:
--------------
abc\x
abc\
PHP Parse error:  syntax error, unexpected T_STRING, expecting ',' or ';' in x:\test.php on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-02 08:40 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 07:01:24 2019 UTC