[eluser]xwero[/eluser]
if you declare a variable inside your class you can use it in all functions of the class.
Let say you have an id that is used by several functions.
Code:
class test
{
var $id;
// set id for the other functions
function test()
{
$this->id = 1;
}
function name()
{
$this->db->query('select name from persons where id=?',array($this->id));
}
function profession()
{
$this->db->query('select name from professions where id=?',array($this->id));
}
}
It's not working code but i think you get the idea. Most of the time a get and set function is added to change the value of the variable.
Var is the php4 keyword, in php5 you can control the scope of the variable with public or private.
So you don't need to put var in front of the variables inside the functions.