On Thu, Feb 25, 2021, at 2:55 AM, Rowan Tommins wrote: > On 24/02/2021 04:26, Mike Schinkel wrote: > > Repeating code similar to that from the message sent by David Rodrigues you > > can see that eliminating the ": null" is less noisy: > > > > <div class="user <?php user ? 'online' : null ?>">...</div> > > <div class="user <?php user ? 'online' ?>">...</div> > > > That's an interesting use case. Of course, the logical default there is > actually '' (empty string) rather than null, since "echo null;" doesn't > actually make much sense, but null works under current type juggling rules. > > Then again, perhaps this is a good example of why PHP *isn't* the best > choice any more if you want a templating language. Twig, for instance, > has exactly this facility > [https://twig.symfony.com/doc/3.x/templates.html#other-operators]:
Given the security implications of plain PHP templating (you're on your own for absolutely all filtering and escaping, good luck), I'd say this isn't even a controversial statement. PHP may have begun life as a templating language for the 90s, but in the 2020s it's a fairly mediocre option at best compared to what else is readily available. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php