#21433 [Opn->Bgs]: Generic expressions interpolation in strings
| From: | tularis@php.net | Date: | Sun, 05 Jan 2003 19:48:39 +0000 |
| Subject: | #21433 [Opn->Bgs]: Generic expressions interpolation in strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-29128@lists.php.net to get a copy of this message | ||
ID: 21433
Updated by: tularis@php.net
Reported By: giannici@neomedia.it
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 4.2.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
I don't think this will be implemented, since this is partially why
heredocs were created.
The only thing I can tell you is, you should use stuff like:
echo "it is: ".++$value;
Previous Comments:
------------------------------------------------------------------------
[2003-01-05 10:35:03] giannici@neomedia.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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21433&edit=1