如果为true,PHP将会挂起一个字符串

I feel like there must be simpler way to do this, but sometimes I want two pieces of text at different points if one case is true.

Here, I'm wrapping stuff in a link in two different ways. They both seem long.

<?=($x)?"<a href='$x'>":""?> stuff <?=($x)?"</a>":""?>

or

$y = "stuff";
if ($x)
  $y = "<a href='$x'>$y</a>";
print $y;

you can do this with ternary operator

echo (isset($x))?"<a href='$x'>$y</a>":$y;

http://codepad.viper-7.com/WbIacO