otha Posted September 15, 2006 Share Posted September 15, 2006 Can a conditional statement be used as the assigning portion of a variable? Quote Link to comment https://forums.phpfreaks.com/topic/20889-variables/ Share on other sites More sharing options...
wildteen88 Posted September 15, 2006 Share Posted September 15, 2006 Course, you can use a ternitry operator. Eg:[code=php:0]$color = 'red';$color = ($color == 'red') ? 'blue' : 'red';[/code]Or the longer version is:[code=php:0]if($color == 'red'){ $color = 'blue';}else{ $color = 'red';}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20889-variables/#findComment-92544 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.