The title is not meant to be misleading, but I didn't have enough space to adequately express my problem. If this has been answered already, I couldn't find it (possibly because of my inability to sum it up). Here goes.
In my script that i'm coding, i'm using object-oriented programming (as can be inferred by the title). I have a global variable (var tableData) thats an array. When I start the class that this variable resides in (user extends i42), i can do a call to user::table() and have it return the name of the table. However, if I call a member function of user from the base class (i42), it will only see itself, no outside functions or the global tableData variable. Here's the code which may lend a better example than my description.
class i42
{
//stuff here
function i42()
{
new user();
user::login();
}
}
class user extends i42
{
var $tableData = array( table => "i42v1_users",
id => "id",
user => "nick",
realname => "realname",
password => "password",
level => "level",
age => "age",
sex => "sex",
location => "location",
aim => "aim",
email => "email",
url => "url",
pic_url => "pic_url");
function user()
{
//session stuff, unimportant
echo $this->table(); //This returns the variable properly
}
function login()
{
//other stuff
function_exists("table"); //returns false
echo user::table(); //returns nothing
}
function table()
{
return $this->tableData["table"];
}
}
new i42;
new user() echos the value stored in tableData["table"] successfully. In login(), however, the function table() is not seen, and the call to it returns nothing. I can't explain this, nor make the function see the variable tableData. Help is much appreciated.