【发布时间】:2016-12-19 19:15:04
【问题描述】:
我遇到了一个非常奇怪的问题,我在通过 isset() 调用后立即抛出了一个 Undefined variable: authenticated_function 异常。代码:
class AuthService
{
static $authenticated_function;
public static function setAuthenticatedFunction($func)
{
\Log::info("Function Set");
self::$authenticated_function = $func;
}
public function authenticated()
{
\Log::info("ISSET: " . isset(self::$authenticated_function));
var_dump(self::$authenticated_function);
if(isset(self::$authenticated_function))
self::$authenticated_function(); //Exception is thrown here
}
}
在我的日志文件中:
[2016-12-19 19:05:08] local.INFO: Function Set
[2016-12-19 19:05:08] local.INFO: ISSET: 1
还有var_dump():
object(Closure)[103]
public 'this' =>
object(App\Providers\AppServiceProvider)[86]
... //Removed for brevity
protected 'defer' => boolean false
PHP 7.0.8
Laravel 5.3
【问题讨论】:
标签: php laravel-5.3 php-7