Re: Global class instances mysteriously set to NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James \(IFMS\) wrote:
> I'm struggling to narrow this down, and am chasing my tail to figure
> this out. I apologise for the imprecise nature.
>
> PHP: 4.3.2 (latest RHEL 3 version; php-4.3.2-19.ent.src.rpm)
> OS: Linux kernel 2.4.21-15.0.3.EL
> Distro: RHEL 3, all updates
>
> I have an app that defines two global class instances, one for the
> database connection, the other for handling user authentication. The
> first is instantiated in uDatabase.php the other in uAuthenticate.php.
>
> In building a page, there are several files that call require_once with
> one or the other file, e.g.
>
> require_once 'uAuthenticate.php';
>
> Which creates an a global instance of a class defined in another file,
> performs some checks, &c.
>
> I'm using require_once with the understanding that once this file has
> been included, that any subsequent require_once call to the same file
> will be ignored.
>
> My problem is that it appreas that in some cases require_once destroys
> the instance, i.e. var_dump($Auth); or var_dump($Database) displays NULL.
>
> I'm currently trying to determine rhyme or reason for the problem, but
> haven't found any pattern. It comes and goes depending on which file
> first calls require_once and the order, but makes no sense.
>
> ANY ideas apreciated. :-)

Most likely, somewhere along the way, one of your files is triggering some
condition which 'unsets' your variable.

It's also possible that you've got your require's out of sequence
somewhere in there.

Personally, I always structure my code so that there is only one place
where any given file will be require'd so I don't need require_once.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux