Jump to content


Photo

variables


  • Please log in to reply
1 reply to this topic

#1 otha

otha
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 September 2006 - 05:25 PM

Can a conditional statement be used as the assigning portion of a variable?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 September 2006 - 05:32 PM

Course, you can use a ternitry operator. Eg:

$color = 'red';

$color = ($color == 'red') ? 'blue' : 'red';

Or the longer version is:
if($color == 'red')
{
    $color = 'blue';
}
else
{
    $color = 'red';
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users