Jump to content

Global variable scope and duration


wepnop

Recommended Posts

Hi, im having a problem using a global object in all my scripts and programs. Its a register singleton so it have all the configuration values, etc...

 

Now im doing:

 

1-I create a script for testing, test.php

2-I include in that script 'errores.php', thats my error system library.

3-The error library include once 'registroglobal.php', thats my file for the global register.

4-Because i can use a lot of systems with a complete library or alone, i created a system where i test if the library module is part of a more greater library or not. If not, it instantiates the global register in errors.php (called in the include in test.php).

5-Here is the problem. Includes add and execute code, so, i must have all errors.php functions and the global register created.

6-If i test the global register in the test.php script, it goes well.

7-But if i call a function of my errores.php system, it says that my global register is undefined.

 

Well, thats all the explanation. Whats going on? How can i solve this?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.