在三元php脚本中,如何将第二个变量连接到字符串中


Inside of a ternary php script how do i concatenate a second variable into my string?

在style="style="color:'之前$rx_event_colors。'"我想添加$ima变量。它只是一个字符串中有图像的变量。此外,如果你认为我可以从添加

 if(!empty($ins_event))
            {
            echo "<tr><td>&nbsp; <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'" . 
            ( $ins_event['status'] == 2 ? ' style="color: ' . $rx_event_colors . '">Completed Insurance Event' : '>Active Insurance Event') . "</a></td></tr>";     
            }

我试过:

? ' $ima, style="style="color: ' . $rx_event_colors . '"
                      style="style="color: ' . $ima, $rx_event_colors . '"
                      style="style="color: ' . ($ima), $rx_event_colors . '"
                      style="style="color: ' . ($ima), ($rx_event_colors) . '"

但无济于事。

我假设$ima是一个字符串。要连接字符串,请使用"."

因此,在三元的第一部分中,如果您想添加$ima,只需执行以下操作:

' style="color: ' . $ima . $rx_event_colors . '">Completed Insurance Event'

然而,当你说"[$ima]只是一个字符串中有图像的变量"时,我会感到困惑。$ima是否包含图像本身的路径?如果是,则它属于img标记的SRC属性,而不是STYLE属性。

更新:

因为$ima包含整个img标记,所以它不属于样式atrribute。参见:

' style="color: ' . $rx_event_colors . '">' . $ima . 'Completed Insurance Event'