On Sun, Jun 5, 2022 at 9:24 AM shinji igarashi <s...@sj-i.dev> wrote:

> Hello everyone,
>
> I'd like to propose adding a new closing tag `=?>` to the language.
>
> PHP currently removes the newline character immediately following
> the closing tag `?>`.
>

Personal opinion, seems like a classic sledgehammer on a nut proposal. I
actually prefer the <?= $whatever . PHP_EOL ?> or ."\n" notation since it
makes it explicitly clear what you're intending to output and keeps it
within the control of the PHP code block. Alternatively it's also enough in
the case of plain text or wherever else this matters to you to just add a
space after the closing tag before the newline (granted there may be niche
situations where this is undesirable).

It's not a breaking change for any existing code, at least, but for me I
still don't see enough of a benefit that I'd think it was worth adding to
the language, as any new syntax creates the potential for confusion and
user error. Is this a big enough problem to be worth any change at all? In
over 15 years of writing PHP, I've never once had a situation where closing
tag newline elision has been an issue.

-Dave


>
> With the new closing tag `=?>`,  the code should look like this:
>
> ```
> - <?= 1 =?>
> - <?= 2 =?>
> - <?= 3 =?>
> ```
>
> and the results it produces would be:
>
> ```
> - 1
> - 2
> - 3
> ```
>
> instead of the following:
>
> ```
> - 1- 2- 3
> ```
>
> This addition requires only a one-line modification to the lexer and
> doesn't break BC. The proposed patch is here.
> https://github.com/php/php-src/pull/8708
>
> Before writing an RFC, I would like to hear your input on whether
> it's worth tackling.
>
> Thanks!
>
> --
> Shinji Igarashi
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>

Reply via email to