Re: [RFC] Alternative syntax for Nowdoc.
| From: | Rowan Tommins | Date: | Tue, 29 Jun 2021 16:40:05 +0000 |
| Subject: | Re: [RFC] Alternative syntax for Nowdoc. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115214@lists.php.net to get a copy of this message | ||
On 29/06/2021 17:15, Manuel Canga wrote:
Hi, folks, here again with a new purpose: ``` as alternative to Nowdoc syntax. Currently, Nowdoc syntax is very "verbose": $string =<<<'CODE' <div> <p>Link: <a href="%s">'%s'</a><p> </div> CODE;The big advantage of heredoc and nowdoc syntax is that you can choose the delimiter to be something that you know won't occur in the string. For instance: $markdown = <<<'MD' PHP has lots of ways to write strings:
$example = 'hello'; $example = "hello"; $example = <<<EXAMPLE hello EXAMPLE; $example = <<<EXAMPLE hello EXAMPLE;MD; Unless I'm missing something, your proposed syntax would just be a *more verbose* way of writing single quotes. Regards, -- Rowan Tommins [IMSoP]