if语句的速记不正确

sys*_*bug 0 php codeigniter

我有以下三元运算符:

<?php (strcmp($activetab,'profile') == 0 ? echo "active" : '');  ?>
Run Code Online (Sandbox Code Playgroud)

不幸的是,它没有按预期工作.我希望,如果条件是真的,那active将得到回应,否则什么都没有.

我究竟做错了什么?

Pra*_*lal 5

现在试试

<?php echo (strcmp($activetab,'profile') == 0) ?  "active" : '';  ?>
Run Code Online (Sandbox Code Playgroud)