php/doc-en

Strings documentation regarding backslash

Offen

#1.804 geöffnet am 07.09.2022

 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)XML (882 Forks)auto 404
enhancementgood first issue

Repository-Metriken

Stars
 (596 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 99T 23h) (90 gemergte PRs in 30 T)

Beschreibung

ref: https://www.php.net/manual/en/language.types.string.php

The description under “Single quoted” says, “To specify a literal backslash, double it (\);” however, in the example we see...

// Outputs: You deleted C:\*.*?
echo 'You deleted C:\*.*?';

... so it seems it is not necessary to double the backslash. Should the instruction for doubling a literal backslash be removed from this section? Alternately, it could be clarified to state that doubling the backslash is optional, and either a single or double backslash will result in a single backslash.

In the “Double quoted” section we see, “As in single quoted strings, escaping any other character will result in the backslash being printed too.” This statement references a table of escaped characters that applies to double quoted strings, but not single quoted strings. I would cut the phrase “As in single quoted strings...” to avoid leading people to think that the table has anything to do with single quoted strings. It's clear enough to say, “Escaping any other character will result in the backslash being printed.”

Contributor Guide