Can you pass by reference while using the ternary operator?
Simple question, simple code. This works: $x = &$_SESSION['foo']; This does not: $x = (isset($_SESSION['foo']))?&$_SESSION['foo']:false; It throws PHP Parse error: syntax error, unexpected '&' . Is it just not possible to pass by reference while using the conditional operator, and why not? Also happens if there's a space between the ? and & . Simple answer: no. You'll have to take the long way around with if/else. It would also be rare and possibly confusing to have a reference one time, and a value the next. I would find this more intuitive, but then again I don't know your code of course: if