Jump to content

Archived

This topic is now archived and is closed to further replies.

otha

variables

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.