I m using zend.
I want to define the below code outside the controller class & access in different Actions.
$user = new Zend_Session_Namespace(\'user
To access a global variable from inside a method/function, you have to declare it as global
, inside the method/function :
class VerifierController extends SystemadminController
{
public function indexAction()
{
global $logInArray;
// action body
print_r($logInArray);
}
}
In the manual, see the section about Variable scope.
Still, note that using global variables is not quite a good practice : in this case, your class is not independant anymore : it relies on the presence, and correct definition, of an external variable -- which is bad.
Maybe a solution would be to :