PHP - symfony2 - Getting error when checking whether Session is set or not -
problem - want check whether session set or not in '__construct' of 'controller', getting following error -
fatalerrorexception: compile error: cannot use isset() on result of function call (you can use "null !== func()" instead)
the following code snippet in '__construct' -
function __construct() { $request = request::createfromglobals(); $session = $request->getsession(); if(!isset($session->get('id'))){ $this->redirect('userauthbundle:auth:login.html.twig'); } }
if use '!= null' instead of '!isset' giving me error following -
fatalerrorexception: error: call member function get() on non-object
is there other alternative way can implemented.
thanks in advance.
warning
isset()
works variables passing else result in parse error. checking if constants set use defined() function.
Comments
Post a Comment