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
 [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: Wed Dec 11 16:01:26 2019 UTC