I already opened a bug (#21433) about this Feature Request, but I
realized it is better to discuss here about it.
I'm relatively new to PHP. Previously I used to program a lot in Perl.
What I really lack in PHP is Perl's ability to interpolate any
expression inside a string.
For example:
Perl: "Next value is @{[ $value + 1 ]}!"
PHP: "Next value is " . $value + 1 . "!"
In this simple case it's not a great problem, but it becomes more
awkward when using the heredoc operator. In this cases I'm often forced
to use temporary variables:
$tempvar = $value + 1;
print <<< END
Here it is the next value
$tempvar
Other text...
END;
I propose to extend the Variable Parsing syntax to evaluate ANY
expression instead of variables only.
I propose the following syntax:
print <<< END
Here it is the next value
{$= $value + 1 }
Other text...
END;
Using "{=" would be more readable but it would cause too many backward
compatibility problems...
What do you think of this?
Thanks.
--
___________________________________________________
__
|- [EMAIL PROTECTED]
|ederico Giannici http://www.neomedia.it
___________________________________________________
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php