Home > Enterprise >  How to write ElseIF Condition In shortForm PHP
How to write ElseIF Condition In shortForm PHP

Time:01-12

So I can do short hand for if and else echo ($role==0?'audtior':'contribute_lead')

but now I have another condition Else if full form will be like this

if($role==0){
$role='auditor';
}
elseif($role==1){
$role='contribute_lead';
}
else{
$role='support team';
}

how can i write this condition in php short Form is this possible????

CodePudding user response:

you can achieve that by using parentheses :

echo $role==0 ? 'auditor' : ($role==1 ? 'contribute_lead' : 'support team');
 
  •  Tags:  
  • Related