Re: [RFC] Alternative syntax for Nowdoc.

From: Date: Wed, 30 Jun 2021 10:51:56 +0000
Subject: Re: [RFC] Alternative syntax for Nowdoc.
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-115234@lists.php.net to get a copy of this message
 ---- En mié, 30 jun 2021 11:03:32 +0200 Guilliam Xavier <guilliam.xavier@gmail.com>
escribió ----
 > Hi,

Hi Guilliam

 > Maybe other syntax could be used, but I don't know which. In javascript
 > > only a backtick is used:
 > > https://developers.google.com/web/updates/2015/01/ES6-Template-Strings
 > > .
 > > But in PHP this is used as eval.
 > >
 > 
 > Just a precision, because you keep referring to it as "eval", which makes
 > me "tick" (haha): $cmd (i.e. $cmd wrapped in a pair of backticks) is
 > the
 > same as shell_exec($cmd), not eval($cmd).

Yes, you're right. 
  
 > (BTW, one of JS "template strings" main selling points is string
 > substitution / variable interpolation, which is explicitly *not* wanted
 > with nowdoc [VS heredoc].)

Yes, I mean that in JS is used some similar (although as you say with variables).
I would prefer to use this "feature" with nowdoc. Normally, strings with variables are
moved to views, while large literals (like queries) are added inline.
 
 > As for the proposal, overall I agree with Rowan -- well, that would not be
 > exactly like single quotes (regarding [not] escaping them), but still "yet
 > another way" to write a nowdoc string literal.

I see this purpose as a simplification of Nowdocs. Just like [] with
array().
  
 > PS: "amusingly", the code samples are hard to understand after rendered on
 > https://externals.io/message/115213

ups!, I'm sorry...but, look at:
https://externals.io/message/115213#115222
Markdown is not broken here due to ``` of code.

Regards,
Manuel Canga


Thread (14 messages)

« previous php.internals (#115234) next »