How to make the code syntactically?

The question was asked: 6 years 10 months ago   views: 21
0

How syntactically correctly to execute the following piece of code:

<?php
if (<?=$arFields['PROPERTY_STATUS_ID']?> == 141) {
 <span style="color: #5da130;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
} elseif (<?=$arFields['PROPERTY_STATUS_ID']?> == 142) {
 <span style="color: #f4c430;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
} elseif (<?=$arFields['PROPERTY_STATUS_ID']?> == 143) {
 <span style="color: #ff002e;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
}
?>
Asked: Max Max 31-05-2012 в 17:33:08
To remove Bitrix forever! - artem artem 31-05-2012 в 17:33:46
@Shrek Plus for the answer! - Артёмыч Артёмыч 31-05-2012 в 17:41:15

Answers   2

0

The syntax depends on the adopted agreements in a framework/engine. If it were Zend, Kohana, Drupal or Joomla, it would look like it all slightly differently. I feel closer to the style of Kohana, it would look like this:

<?if (intval($arFields['PROPERTY_STATUS_ID']) == 141) :?>
<span style="color: #5da130;">
<?=$arFields['PROPERTY_STATUS_VALUE']?>
</span>
<?elseif (intval($arFields['PROPERTY_STATUS_ID']) == 142) :?>
<span style="color: #f4c430;">
<?=$arFields['PROPERTY_STATUS_VALUE']?>
</span>
<?elseif (intval($arFields['PROPERTY_STATUS_ID']) == 143):?>
<span style="color: #ff002e;">
<?=$arFields['PROPERTY_STATUS_VALUE']?></span>
<?endif;?>
Answered: kemerov4anin kemerov4anin 04-06-2012 в 21:34:37
0

If anyone is interested, here is the solution I found:

<?if (intval($arFields['PROPERTY_STATUS_ID']) == 141) {?>
 <span style="color: #5da130;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
<?} elseif (intval($arFields['PROPERTY_STATUS_ID']) == 142){?>
 <span style="color: #f4c430;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
<?} elseif (intval($arFields['PROPERTY_STATUS_ID']) == 143){?>
 <span style="color: #ff002e;"><?=$arFields['PROPERTY_STATUS_VALUE']?></span>
<?}?>
Answered: Артёмыч Артёмыч 31-05-2012 в 18:01:02
Yes, much better. 142. - Costantino Rupert Costantino Rupert 31-05-2012 в 23:03:59