You are here: the global key word « PHP Programming Language « IT news, forums, messages
the global key word

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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация