Reputation: 8524
I have a global object, a "registry", it is a container with other important objects:
I need to have this global object in every place (object), where I process my request.
Like in my JBoss environment, where I have one Stateful Session Bean as a front controller, which directs the processing to a special Stateless Session Bean, I have one entry point, "facade.php".
In this facade.php, I create the global object and place the other objects (input object, ...) into it.
Then there is a large switch statement, where I redirect the request to special processing objects.
Is there a method, mechanism, to have access to this general object from the processing objects without handing it over as a parameter?
Upvotes: 0
Views: 130
Reputation: 20889
What you can do:
global
keyword. http://php.net/manual/en/language.variables.scope.phpUpvotes: 2
Reputation: 15616
To have a variable available everywhere you can use a $_SESSION
variable like so:
session_start();
$_SESSION['registry'] = // Your data
Make sure to use the session_start()
function whenever you want access to the session variables.
Upvotes: 2