Re: Adding new closing tag =?> for keeping trailing newline
| From: | shinji igarashi | Date: | Sun, 05 Jun 2022 22:36:03 +0000 |
| Subject: | Re: Adding new closing tag =?> for keeping trailing newline | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117856@lists.php.net to get a copy of this message | ||
> <?= $whatever . PHP_EOL ?> or ."\n"
Yeah, adding an explicit newline character is a workaround for this.
However, what if that output content were moved to a location other
than the end of a line when editing the template? It would be
necessary to remove the extra newline character each time
they move from the end of a line.
With this new closing tag, the behavior of the output block can be
position-independent.
Your concerns are valid and I agree that this is a small difference.
What I am not sure about is how many people want this small
difference, so I'm asking around in some parts of the community.
Thanks for your feedback!
--
Shinji Igarashi
2022年6月6日(月) 6:31 David Gebler <davidgebler@gmail.com>:
>
> On Sun, Jun 5, 2022 at 9:24 AM shinji igarashi <sji@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
>>