vForums Support > Programming & Coding :: Programming Discussion :: > Using methods from one class in another class

Using methods from one class in another class - Posted By Dylan (dylan) on 25th Mar 08 at 8:26pm
Ok I have 2 classes a Database class and Miscellaneous class, The database class has mysql connection info and all the methods I use. I then have a miscellaneous class which has random methods I use. The problem is I need the miscellaneous class to use methods in from the database class. But I don't know how to create a new class int htere like the usual thing to do is
$db =new Database;

if I try that I get this
Quote:
arse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/djago/public_html/socialnetworking/framework/misc.php on line 3


if I add this line
var $db =new Database;
Quote:

Parse error: syntax error, unexpected T_NEW in /home/djago/public_html/socialnetworking/framework/misc.php on line 3


What do I do?

Re: Using methods from one class in another class - Posted By Mithras (mithras) on 25th Mar 08 at 9:13pm
I think I answered this on PBS, but just in case anyone here has the same question, you would do something like this:

$db = new Database();
$db->method();

Re: Using methods from one class in another class - Posted By Dylan (dylan) on 25th Mar 08 at 10:44pm
Thank you {Smile}

Re: Using methods from one class in another class - Posted By Mithras (mithras) on 26th Mar 08 at 12:14am
Glad to help {Smile}