Hi,

Le Monday 17 October 2011 15:07:30, Alain Williams a écrit :
> On Fri, Oct 14, 2011 at 08:08:56PM +0200, Arnaud Le Blanc wrote:
> > Hi,
> > 
> > I've already posted this patch and it has since been reviewed and
> > improved. I'm re-posting it for discussion before eventually commiting
> > it.
> > 
> > The ternary operator always copies its second or third operand, which is
> > very
> 
> > slow compared to an if/else when the operand is an array for example:
> Is that why the following does not work as I expected:
> 
>     $dbh = $how == 'r' ? (&$dbh_r) : (&$dbh_w);
> 
> $dbh is NOT a reference to $dbh_r or $dbh_w.

This is expected; 
http://docs.php.net/manual/en/language.operators.comparison.php explains it:

> Please note that the ternary operator is a statement, and that it doesn't 
evaluate to a variable, but to the result of a statement.

This is why you can't assign the result of the ternary operator by reference. 
The patch doesn't change this.

Best regards,

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

Reply via email to