Posted by Manny on 06/25/07 23:39
Hello fellow programmers,
Recently I've run into an interesting bug? or possibly my own
ignorance. I wrote a class (php 4) and in the constructor made an
array global. Now the array is included into the file as a
configuration mechanism. However, the constructor for what ever reason
does not recognize the imported variable. Here's a summarized version
of the source:
config.inc:
$db['user'] = "foo";
$db['pass'] = "bar";
class.db.php:
require_once('config.inc');
Class db
{
var $user
var $pass
function db()
{
global $db;
}
}
After that point initialization occurs but $db never gets read into
the internal variables... can anyone explain this seemingly anomolous
event to me?
[Back to original message]
|