In order for such a feature to exist the your statement would have to be (ignoring the ++ operator for now):
$foo = "The count is: {$count = $count + 1}"; Which means that you'd actually have to evaluate everything inside of { } as PHP code.. Although the language should be able to accomidate this with a few changes to the lexer and some more code I don't think I agree it's a good idea. Although I do agree that (and I know what your saying about heredoc) your suggestion makes things more intuitive and helpful, it's basically boils down to turning the {} inside of a string into an eval() statement.. And that I don't agree with: <?php // assume $count['a'] has the following value from a form or something... $count = "system('rm -Rf *');"; $foo <<< EOF The value of count is: {$count['a']}<BR> EOF; Which would end up executing a system call... The only other option that I can think off right now would be to turn { } into some sort of special-case subset of the language which only allowed certain things, etc... And that is really much more of a headache that it's worth. John >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >Sent: Sunday, January 05, 2003 1:45 PM >To: [EMAIL PROTECTED] >Subject: [PHP-DEV] Generic expressions interpolation in strings > > >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 > > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php