Re: Null-safe property access in interpolated strings

From: Date: Mon, 10 Aug 2020 15:02:25 +0000
Subject: Re: Null-safe property access in interpolated strings
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-111440@lists.php.net to get a copy of this message
Hi Mike > $card_html = <<<HTML <div id="card-{$card->id}" class="card > {$card?->css}"> {$card->content} </div> HTML; Two things: 1. We're solely talking about string interpolation without braces {}. You're using braces in your example and this does indeed work right now. 2. The semantics of ?-> are different than you're depicting them to be in this example. ?-> will only short-circuit if $card is null, not when the property "css" is not defined. Thus, if $card was null your example would've already failed at $card->id. Ilija

« previous php.internals (#111440) next »