webbhelp Posted March 27, 2011 Share Posted March 27, 2011 Hi! I have a class with many functions/methods. I want to split this into different files so I can easily edit and add functions. I want every functions to be able to call eachother and with that I mean, they have to be for example in same document. My question is: I can't have a class and include functions like this: class DB { include('select_functions.php'); //Only includes function's no class include('insert_functions.php'); //Only includes function's no class include('delete_functions.php'); //Only includes function's no class function test() { } } The includes will output fatal errors... How can I solve this so I can have all functions in different files but still use ONE object to call them! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/231868-include-functions-in-a-class/ Share on other sites More sharing options...
KevinM1 Posted March 27, 2011 Share Posted March 27, 2011 You're going about this the wrong way. Classes can't be split up like you want them to be. If you feel your class is flawed due to its length, you should look into refactoring it into other, smaller classes. In any event, you're also trying to reinvent the wheel when PHP already has several OOP database options available to use - MySQLi and PDO. Look into them to see if they'd fit your needs. Quote Link to comment https://forums.phpfreaks.com/topic/231868-include-functions-in-a-class/#findComment-1193045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.