Re: [RFC] Alternative syntax for Nowdoc.

From: Date: Tue, 29 Jun 2021 19:33:19 +0000
Subject: Re: [RFC] Alternative syntax for Nowdoc.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115220@lists.php.net to get a copy of this message
Hi Manuel,

wt., 29 cze 2021 o 18:16 Manuel Canga <php@manuelcanga.dev> napisał(a):

> 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;
>
> Why doesn't something like this?:
>
> $string =```
> <div>
> <p>Link: <a href="%s">'%s'</a><p>
> </div>
> ```;
>
> even as well:
>
> $string =``<div><p>Link: <a
> href="%s">'%s'</a><p></div>``;
>
>
> I see a caveat: this is very similar to eval syntax. However, this
> syntax is more similar to Markdown syntax.
>
> What do you think ?
>

I think a Markdown document including PHP code snippet with above examples
could cause issues while parsing.
I can imagine parsers don't expect end-of-snippet tag "```" being not an
end tag actually.

Cheers,
Michał Marcin Brzuchalski


Thread (14 messages)

« previous php.internals (#115220) next »