Re: RFC: Short echo tag can also call closures
| From: | Shailesh Humbad | Date: | Mon, 18 Sep 2023 20:24:01 +0000 |
| Subject: | Re: RFC: Short echo tag can also call closures | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121099@lists.php.net to get a copy of this message | ||
On 9/18/2023 3:36 PM, Larry Garfield wrote:
I can see where you're going with this, but as others have noted I don't think it's really the right way to go about it. If the property hooks RFC passes (we're stalled a bit trying to put together benchmarks, sorry), that will solve this use case in a much cleaner and more generic way. (A property could be virtual, and backed by arbitrary logic to do all the same streaming that you're talking about here.) --Larry GarfieldYes, property hooks <https://wiki.php.net/rfc/property-hooks> would be perfect! I use that syntax all the time in C#, and love it. I vote for that instead. In the meantime, I will use Robert Lander's idea and create a helper method, something like this: <?= EchoCallable($model->body); ?> Thanks for all your feedback everyone. Regards, Shailesh