我正在从GET
设置一些变种
$start = $_GET['start'];
$end = $_GET['end'];
我从中得到:
start=1-11-2018&end=30-11-2018
然后我正在做
if((!$start) && (!$end)) {
if (($dateFormat >= $start) && ($dateFormat <= $end)) {
} else {
echo "no dates";
}
并关闭它
if((!$start) && (!$end)) {
}
}
但是这没有发生
if((!$start) && (!$end)) {
更新
现在这可以正常工作,但是如果没有GET不会进入其他
if((!empty($_GET['start'])) && (!empty($_GET['end']))) {
if (($dateFormat >= $start) && ($dateFormat <= $end)) {
} else {
echo "No dates";
}
答案 0 :(得分:0)
如果您正在呼叫:http://example.com?start=1-11-2018&end=30-11-2018
class Master: existent = {} init_OK = False def __init__(self, key, value=None): if not Master.init_OK: raise Exception('Direct call to Master() is not allowed') Master.init_OK = False self.key = key self.value = value Master.existent[key] = self @staticmethod def make(key, value=None): try: inst = Master.existent[key] except: Master.init_OK = True inst = Master(key, value=value) return inst
1. The isset() is checking query string "start"/"end" is having or not.
2. The empty() is checking query string "start"/"end" is empty/blank or not
答案 1 :(得分:-2)
这是我的解决方法:
if((!empty($start)) && (!empty($end))) {
if (($dateFormat >= $start) && ($dateFormat <= $end)) {
}
// here the content which
// in case those vars are not empty,
// would get filtered by that logic.
if((empty($start)) && (empty($end))) {
// Close the condition for second if when not empty
} else {
echo "No dates";
}