我有以下代码来检查开始和结束时间,它运行正常。
// MyClass has an abstract method named "AbstractMethod"
MyClass class_object = new MyClass()
{
@Override
public void AbstractMethod()
{
// Do something here
}
};
class_object.AbstractMethod();
我想要实现的是从xml文件中获取时间,但它无法正常工作
// Set open and closing time for each day of the week
if ($weekday == "Monday") {
$open_from = "17:00";
$open_to = "21:45";
}
我在另一个参数中使用此代码,它工作正常。
// 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 ?>";
}
答案 0 :(得分:2)
您可以直接访问$modayopen
和$mondayclose
,无需回复:
// Set open and closing time for each day of the week
if ($weekday == "Monday") {
$open_from = $mondayopen->nodeValue;
$open_to = $mondayclosed->nodeValue;
}
答案 1 :(得分:0)
你的php代码应该是这样的
if ($weekday == "Monday") {
$open_from = $mondayopen->nodeValue;
$open_to = $mondayclosed->nodeValue;
}
//(or)
if ($weekday == "Monday") {
$open_from = '"'.$mondayopen->nodeValue.'"';
$open_to = '"'.$mondayclosed->nodeValue.'"';
}