此对象中的任何变量都是!isset(),但是如果我是var_dump($ interval)或print_r($ interval),则这些变量将成为isset()。这也适用于empty()/!empty()。
Any variable in this object is !isset() but if I either var_dump($interval) or print_r($interval), these variables becomes isset(). This also applies to empty()/!empty().
因此在$ interval-> i下面的代码中,最初是!isset(),但在我之后是isset() var_dump($ interval)。
So in the code below $interval->i is initially !isset() but isset() after I var_dump($interval).
$future = new DateTime("2018-08-24"); $now = new DateTime(); $interval = $future->diff($now); if (isset($interval->i)) { echo 'isset' . $interval->i; } else { echo 'not isset' . $interval->i; } var_dump($interval); if (isset($interval->i)) { echo 'isset' . $interval->i; } else { echo 'not isset' . $interval->i; }可能是什么原因导致它们最初是!isset并且为空,但是isset
What could possibly be causing these to be !isset and empty initially, but isset and !empty afterwards?
推荐答案不确定是否要使用哪个版本的PHP,但要使用PHP 7.0.5。它是一个错误。
Am not sure which version of PHP you are using but Use PHP version 7.0.5. Its a bug.
这应该很有用: bugs.php/bug.php?id=69587
更多推荐
PHP DateTime DateInterval isset在var
发布评论