I think it's a non-starter because it would change how the existing
code is interpreted.

E.g. currently
```
<?php $title = 'rand'; ?>
<h1><?= $title ?></h1>
```

outputs `rand`, but with your proposal it would invoke `rand()` and
output its result.

On Mon, Sep 18, 2023 at 8:19 PM Shailesh Humbad
<shail...@atensoftware.com> wrote:
>
> Hello,
>
> I'm gauging interest on a proposed change to the short echo tag "<?=".
>
> CURRENTLY:
> The short echo tag "<?= $x ?>" is equivalent to "<?php echo $x ?>",
> which allows for beautiful MVC views like this:
>
> <html>
> <head><title><?= $model->title ?></title></head>
> <body><?= $model->body ?></body>
> </html>
>
> INSTEAD:
> Change the short echo tag "<?= $x ?>" to be equivalent to "<?php
> is_callable($x) ? $x() : echo $x; ?>", which allows view model
> properties to be defined as closures.  This syntactic sugar would
> encourage higher-performance coding practices, since it allows for
> content to be streamed rather than buffered into memory before being
> output.  (Note that there is no need to pass any parameters to the
> closure, or even have that as an option.)  Here is a sample:
>
> $model = new StdClass();
> $FileName = 'LargeFile.html';
> $model->bodyStream = function () use $FileName { readfile($FileName); };
>
> <html>
> <head><title><?= $model->title ?></title></head>
> <body><?= $model->bodyStream ?></body>
> </html>
>
> Thank you for considering!
>
> Regards,
> Shailesh
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>


-- 
  Best regards,
      Bruce Weirdan                                     mailto:weir...@gmail.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to