[Solved] Using registry.php to store objects

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ChrisBull
Forum Commoner
Posts: 42
Joined: Fri Aug 20, 2010 7:43 am

[Solved] Using registry.php to store objects

Post by ChrisBull »

My website at the moment runs like this,
index.php - includes config.php->
config.php - sets variable, $siteRegistry = Registry::singleton();
- disects url and creates new object depending what url says, so http://www.site.com/login creates new login object.
loginObject - created inside config.php
- creates new loginModel
loginModel - Needs to access $siteRegistry but shows following error,

Notice: Undefined variable: siteRegistry in F:\Projects\application\models\loginModel.php on line 37

This is line 37 -

Code: Select all

$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?
Last edited by ChrisBull on Sun May 01, 2011 6:04 pm, edited 1 time in total.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Using registry.php to store objects

Post by McInfo »

If line 37 is within a function, you need to declare $siteRegistry global.
ChrisBull
Forum Commoner
Posts: 42
Joined: Fri Aug 20, 2010 7:43 am

Re: [Solved] Using registry.php to store objects

Post by ChrisBull »

Thanks Man
Post Reply