我有以下代码来检查开放和关闭时间,它运行良好。
// Set open and closing time for each day of the week
if ($weekday == "Monday") {
$open_from = "17:00";
$open_to = "21:45";
}
我想实现的是从xml文件中获得几个小时,但它不起作用
// Set open and closing time for each day of the week
if ($weekday == "Monday") {
$open_from = "<?php echo $mondayopen->nodeValue ?>";
$open_to = "<?php echo $mondayclosed->nodeValue ?>";
}
我在另一个参数中使用了这段代码,它运行良好。
<tr><td class="text-left">Monday</td>
<td class="text-right"><?php echo $mondayopen->nodeValue ?> - <?php echo $mondayclosed->nodeValue ?></td>
</tr>
您可以直接访问$modayopen
和$mondayclose
,不需要回显:
// Set open and closing time for each day of the week
if ($weekday == "Monday") {
$open_from = $mondayopen->nodeValue;
$open_to = $mondayclosed->nodeValue;
}
您的php代码应该是这样的
if ($weekday == "Monday") {
$open_from = $mondayopen->nodeValue;
$open_to = $mondayclosed->nodeValue;
}
//(or)
if ($weekday == "Monday") {
$open_from = '"'.$mondayopen->nodeValue.'"';
$open_to = '"'.$mondayclosed->nodeValue.'"';
}