Hey.
How can I use a variable throughout a class, when the variable is actually the instance of another class? For example, I have a class that goes like this:
But when I execute this code, I get the following error:Code:require_once("a.inc.php"); require_once("b.inc.php"); require_once("c.inc.php"); $a=new a; $b=new b("argument"); $c=new c; class d { var $uid; function d() { $set=$a->getid(); //getid() is a function in the class 'a' that returns an array. //From that array we need to extract the value of 'uid' $this->uid=$set['uid']; } function getd() { $sql="SELECT d FROM data WHERE uid='$uid'"; $c=$b->makequery("d",$sql); //makequery() is a function of the class 'b' return $c[0]; } }
on the line:Call to a member function on a non-object
Basically what I want is that the variables $a,$b, and $c that are instances of classes a,b, and c remain available throughout the new class d. Please tell me why I got that error and how to make those classes available throughout the new class without using a $a=new a in every function, and if you have any suggestions on how to optimize this code that would be helpful too$set=$a->getid();![]()






Bookmarks