ternary operator & multiple conditions
Posted: Mon Dec 04, 2006 11:52 am
Does the ternary handle multiple conditions? or is only for single contidional statements.
ie: I know this is legal
do multiple conditions work?
Reason for my asking is that I'm lazy
. I already have series of ternary statements with single conditions and I don't feel like changing them to full blown 'if' statements, but I will if ternary operators don't handle multiple conditions.
As always, laziness breeds innovations & new thinking
ie: I know this is legal
Code: Select all
$firstname = (isset($_POST['fname'])) ? $_POST['fname'] : -1;Code: Select all
$firstname = (isset($_POST['fname']) && ereg("^[a-zA-Z]+$", $_POST['fname'])) ? $_POST['fname'] : -1;Reason for my asking is that I'm lazy
As always, laziness breeds innovations & new thinking