Drupal:如何创建包含条件的字符串'如果包含?

Is is possible to create a String variable like this :

$myString = 'the weather is ' . if ($weather == 'good') {'very good'} else {'very bad'};

It means that if my variable $bad contains the value 'good', $myString is equal to :

'the weather is very good'

I know that I can divide my line in some others instructions but I want to do in only ONE instruction.

Do you understand what I want to do?

Thank you very much,

Bat

This should do the trick for you.

$myString = 'the weather is ' . ($weather == 'good' ? 'very good' : 'very bad');
$myString = 'the weather is ';
$myString .= ($weather == 'good') ? 'very good' : 'very bad';