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
https://forums.phpfreaks.com/topic/229361-global-variable-scope-and-duration/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.