From: [EMAIL PROTECTED]
Operating system: Any
PHP version: 4.2.2
PHP Bug Type: Feature/Change Request
Bug description: Generic expressions interpolation in strings
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.
--
Edit bug report at http://bugs.php.net/?id=21433&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=21433&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=21433&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=21433&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=21433&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=21433&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=21433&r=support
Expected behavior: http://bugs.php.net/fix.php?id=21433&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=21433&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=21433&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=21433&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21433&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=21433&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=21433&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=21433&r=gnused