Bug #81635 [Com]: No example of complex interpolation syntax with filenames
| From: | shealavington at gmail dot com | Date: | Thu, 18 Nov 2021 14:49:11 +0000 |
| Subject: | Bug #81635 [Com]: No example of complex interpolation syntax with filenames | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237854@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81635&edit=1
ID: 81635
Comment by: shealavington at gmail dot com
Reported by: shealavington at gmail dot com
Summary: No example of complex interpolation syntax with
filenames
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 10
PHP Version: 8.0.12
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> Understandable, but we can't change long-standing and mostly well-documented behavior just
> because of that. :)
I completely agree, I appreciate your comments! Ah, Perhaps a misunderstanding, I consider
' a single-quoted string and " a double-quoted string haha.
There's too much technical jargon to consider when you're deep in an issue.
Previous Comments:
------------------------------------------------------------------------
[2021-11-18 14:29:24] cmb@php.net
> As in single-quoted strings, [â¦]
That means "like in single-quoted strings". :)
You can often get away without escapting literal backslashes,
but you should not rely on that, especially in double-quoted
strings, since new escape sequences might be introduced, breaking
your code; e.g. \e has been introduced with 5.4.4.
> [â¦] however, due to legacy systems in place, I'm trying to not
> modify too much of the original code.
Understandable, but we can't change long-standing and mostly
well-documented behavior just because of that. :)
------------------------------------------------------------------------
[2021-11-18 14:18:51] shealavington at gmail dot com
Regarding the comment from the docs, it states specifically in single-quoted strings. I am doing
this in a double-quoted string. I'm not sure if that poses an issue or just a documentation
change.
| As in single-quoted strings, escaping any other character will result in the backslash being
printed too.
In reference to escaping file paths, I completely agree they should be, however, due to legacy
systems in place, I'm trying to not modify too much of the original code.
------------------------------------------------------------------------
[2021-11-18 14:18:33] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/59244d9ae93cc5059a07c7eadf36b02a1704512c
Log: Fix #81635: No example of complex interpolation syntax with filenames
------------------------------------------------------------------------
[2021-11-18 13:55:32] cmb@php.net
Nah, there is nothing special about \{[1]:
| As in single quoted strings, escaping any other character will
| result in the backslash being printed too.
Still, it makes sense to add an example, since backslashes in
filenames and the given use-case are common on Windows.
[1] <https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double>
------------------------------------------------------------------------
[2021-11-18 13:37:43] cmb@php.net
Thanks for the further clarification!
> $newFoo = "(FILENAME='C:\folder\{$var}.txt')"
You really should escape the backslashes in the first place;
then you get the desired output: <https://3v4l.org/EKFq2>.
> As you mentioned, \{ should not be escaping, but does.
Indeed: <https://3v4l.org/lLZqF>. That needs to be fixed
in the
docs.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=81635
--
Edit this bug report at https://bugs.php.net/bug.php?id=81635&edit=1