pgm8705 Posted May 1, 2008 Share Posted May 1, 2008 I'm somewhat experienced with php as a scripting language, but I recently decided to make some of my web site more object oriented. I am very familiar with how OO works as I have had a lot of experience with java. My problem is this: I have a class file called dataaccess.php. It is a object which accesses my database. Previously I had included it in the header of every single page. After going through and making objects for most things, I inlcuded it in the top of the class files which need it because this is how you would do things in other OO languages. My problem is that if i create 2 objects on the same page, I get a re-declaration error. What is the appropriate way have classes use other objects without getting this error, and still keeping things modular and abstract? Link to comment https://forums.phpfreaks.com/topic/103770-include-problem/ Share on other sites More sharing options...
trq Posted May 2, 2008 Share Posted May 2, 2008 For starters you could look at require_once, but for a more efficient solution you should look at __autoloading your objects. Link to comment https://forums.phpfreaks.com/topic/103770-include-problem/#findComment-531469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.