0

hi guys. i am writing a class for registering data and i am having a problem calling functions and vars from other classes.

here's a class diagram of where everything is called-

[IMG]http://img376.imageshack.us/img376/19/classesdm8.png[/IMG]


i am in forms, and i am having difficulty getting vars from site, using my functions in postgredb and vars from user.

i can get data from form easily.

$this->var

but when i try getting data from site i get an fatal saying site is not a member of form, ($this->site->var) so, how do i call data from a parent class?


solved
solved it- used a public $p; then set $form->p = $this, and then when calling parent date - $this->p->var...

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by somedude3488
0

example:

class test {
var $var;
function __construct() {
$this->var = 'something';
}
function testing() {
echo 'This is the parent function';
}
}

class test2 {
var par;
var var2;
function __construct( &$par ) {
$this->par = $par;
}
}

$test = new test();
$test2 = new test2( $test );

$test2->par->testing() //will echo 'this is the parent class';

thats one way to do it. there are more.

0

if the thread is solved, please mark it as so. This way I don't waste anymore time replying to something that you already figured out.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.