bmilliron Posted November 9, 2007 Share Posted November 9, 2007 Since it is a good idea to put PHP class definitions in separate files. Do you need to make a reference to the class file when creating an object? How does PHP know what file contains the class definition? Thanks, -Ben Quote Link to comment https://forums.phpfreaks.com/topic/76676-class-files/ Share on other sites More sharing options...
pocobueno1388 Posted November 9, 2007 Share Posted November 9, 2007 You include the file at the top of your script that your using the class in. include "myclass.class.php"; Quote Link to comment https://forums.phpfreaks.com/topic/76676-class-files/#findComment-388204 Share on other sites More sharing options...
bmilliron Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks, pocobueno, so the include statement is used like the import statement in Java right? Quote Link to comment https://forums.phpfreaks.com/topic/76676-class-files/#findComment-389124 Share on other sites More sharing options...
redbullmarky Posted November 11, 2007 Share Posted November 11, 2007 yep. if you're on PHP5, and you keep things fairly well organised with a consistent naming structure, you can make use of the __autoload magic function to wrap your includes in. this saves having to use includes all over the place. Quote Link to comment https://forums.phpfreaks.com/topic/76676-class-files/#findComment-389126 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.