Re: Null-safe property access in interpolated strings
| From: | Mike Schinkel | Date: | Mon, 10 Aug 2020 13:56:23 +0000 |
| Subject: | Re: Null-safe property access in interpolated strings | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111434@lists.php.net to get a copy of this message | ||
>
> On Aug 9, 2020 at 3:00 PM, <Deleu (mailto:deleugyn@gmail.com)> wrote:
>
>
>
> I like and make use of interpolation, but I can't think of a use case for this. Is there
> any valid use case that would benefit from this fix regardless of personal preference? In other
> words, where would one use string interpolation with an empty string being a valid case?
>
>
While I agree with Jordi and Nikita that language consistency is the important metric, here is a
valid case I come across frequently; the need to output optional CSS classes since you ask, fwiw:
>
>
>
>
>
>
> <?php
$card_html = <<<HTML <div id="card-{$card->id}" class="card
{$card?->css}"> {$card->content} </div> HTML;
-Mike