vForums Support Banner


Visit Base Classics - Gaming Chairs

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Using methods from one class in another class - View Topic
Topic Rating: *****
Printable View
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Using methods from one class in another class (25th Mar 08 at 8:26pm UTC)
how do i use the method of one class in another class?
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?


Image
Mithras
Junior Member
**

Posts: 67
Status: Offline
Gender: Male
Location: Pittsburgh, PA
Age: 33
Joined:  
Reputation: 0%  


pm
Re: Using methods from one class in another class (25th Mar 08 at 9:13pm UTC)
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();
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Re: Using methods from one class in another class (25th Mar 08 at 10:44pm UTC)
Thank you {Smile}


Image
Mithras
Junior Member
**

Posts: 67
Status: Offline
Gender: Male
Location: Pittsburgh, PA
Age: 33
Joined:  
Reputation: 0%  


pm
Re: Using methods from one class in another class (26th Mar 08 at 12:14am UTC)
Glad to help {Smile}
 Printable View

All times are GMT+0 :: The current time is 10:42am
Page generated in 1.8479 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums