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

在三元php脚本中,如何将第二个变量连接到字符串中?,php,Php,在style=“style=”color:'之前$rx_事件_颜色。”“我想添加$ima变量。它只是一个在字符串中包含图像的变量。此外,如果您认为只添加 if(!empty($ins_event)) { echo "<tr><td>&nbsp; <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'" .

在style=“style=”color:'之前$rx_事件_颜色。”“我想添加$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是一个字符串。要连接字符串,请使用“.”

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

' style="color: ' . $ima . $rx_event_colors . '">Completed Insurance Event'
但是,当您说“[$ima]只是一个字符串中包含图像的变量”时,我感到困惑。$ima是否包含图像本身的路径?如果是,它属于img标记的SRC属性,而不属于STYLE属性

更新:

由于$ima包含整个img标记,因此它不属于样式属性。请参阅:

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

(点)不是,(逗号)在PHPW的concatanator中,为什么您如此渴望使用三元运算符。如果代码变得不可理解且难以调试,则毫无意义。对不起,是的,它也包含路径。您能否提供一个示例,说明$ima中到底包含了什么?$ima=”";哦$ima变量包含整个img标记。如果是这种情况,那么就不能将$ima放在另一个标记的属性中。我相信您要做的是将图像添加到样式化单词之前(作为某种要点)。试试这个:
“style=“color:”.$rx\u event\u colors.“>”$伊玛“已完成保险事件”
这样$ima就位于正在设置样式的a标记内,而不是其样式属性内。
' style="color: ' . $rx_event_colors . '">' . $ima . 'Completed Insurance Event'