满足条件时在echo语句中回显

时间:2015-03-30 19:15:15

标签: php echo

是否可以在echo语句中回显?

我有一个if语句,如果满足时间条件,则回显HTML元素。我想回应echo $ rows [' SOMETHING'];在这个回声中。所以...

   if ($whatdayisit === Monday && $gmt <= $rows['opening_monday_to'] && $gmt >= $rows['opening_monday_from'])
          {
            echo'<div class="opening_times_times_orange"> ***** echo $rows['opening_monday_from'] . " " . "-" . " " $rows['opening_monday_to'] ***** </div>';
          } 

          else echo '<div class="opening_times_times_red">***** echo $rows['opening_monday_from'] . " " . "-" . " " $rows['opening_monday_to'] ***** </div>';
        ?>

我想回应*****之间的什么,但它不允许我使用当前的脚本。

我如何解决此问题

if ($whatdayisit === Monday && $gmt <= $rows['opening_monday_to'] && $gmt >= $rows['opening_monday_from'])
{ 
echo'<div class="opening_times_times_orange"> HERE </div>';
} 
else echo '<div class="opening_times_times_red"> HERE </div>';

HERE(1)echo $rows['opening_monday_from'];echo $rows['opening_monday_to']; 这里(2)echo $rows['opening_monday_from'];echo $rows['opening_monday_to'];

1 个答案:

答案 0 :(得分:0)

试试这个: -

if ($whatdayisit === Monday && $gmt <= $rows['opening_monday_to'] && $gmt >= $rows['opening_monday_from'])
          {
            echo'<div class="opening_times_times_orange"> *****'. $rows['opening_monday_from']. " " . "-" . " ".$rows['opening_monday_to'].' ***** </div>';
          } 

          else echo '<div class="opening_times_times_red">*****'.$rows['opening_monday_from'] . " " . "-" . " " .$rows['opening_monday_to'].' ***** </div>';
        ?>