note 110259 deleted from language.types.string by cmb
| From: | cmb@php.net | Date: | Sun, 04 Aug 2019 09:13:39 +0000 |
| Subject: | note 110259 deleted from language.types.string by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211804@lists.php.net to get a copy of this message | ||
Note Submitter: mcamiano at ncsu dot edu
----
Regarding the lack of complex expression interpolation, just assign an identity function to a
variable and call it:
function id($arg) { return $arg; }
$expr = id;
echo "Field is: {$expr( "1 ". ucfirst('whatzit')) }";
It is slower due to an additional function call, but it does avoid the assignment of a one-shot
temporary variable. When there are a lot of very simple value transformations made just for display
purposes, it can de-clutter code.