Reputation: 167
My website at the moment runs like this,
index.php
config.php
sets variable, $siteRegistry = Registry::singleton();
also disects url and creates new object depending what url says, so www.site.com/login creates new login object.
loginObject
created inside config.php
creates new loginModel
loginModel
Notice: Undefined variable: siteRegistry in F:\Projects\application\models\loginModel.php on line 37
This is line 37 -
$siteRegistry->storeObject("PDOExtender", "DBO");
I believe the problem is that it can't find the $siteRegistry variable from config.php, does anyone know how to fix this?
Upvotes: 0
Views: 303
Reputation: 410
$siteRegistry = Registry::singleton();
As Registry (what ever it might be) is a singleton there is no need to use this $siteRegistry variable as a global.
In fact you should always call Registry::singleton
inside each function you want to use it.
If that is to long just create a small wrapper function:
function reg() {
return Registry::singleton();
}
The whole purpose of singleton objects is that there is always only one of them at a time, so you can always get them again during the programs execution without having to use variables.
Upvotes: 1