otha Posted September 15, 2006 Share Posted September 15, 2006 Can a conditional statement be used as the assigning portion of a variable? 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] Link to comment https://forums.phpfreaks.com/topic/20889-variables/#findComment-92544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.