I've read tutorial on tutorial and I try to work with Object Oriented PHP but the thing is that I find it rather complex. When I create a class I must include it in the current working document. It doesn't work as in Java when the compiler finds the script in the same folder anyway. And when I always must include that class in different directories it gets really inefficient. Is there a way to achieve what I'm looking for? Or have I completely misunderstood the concept in PHP?

Today I have a script which automatically fixes the correct directory relative from the current working directory and return to me an array with paths so that I can write...


To get the path to the db_class. How should I proceed to achieve effective programming? And how exactly do I use :: ?

Clotoss commented: Very good at explaning things. +0

What are you using as an editor? Notepad ++? And are you testing the code on a website, or some other type of software?

I believe what you are looking for is autoloading, which php does have. http://php.net/manual/en/language.oop5.autoload.php

As far as the :: are you referring to the context of self:: static:: etc or are you referencing namepspaces as the use of :: in namespaces was dropped in lieu of \

I'm using Netbeans IDE 6.9.1. The autoloading class is exactly what I'm looking for! But would it be better to include multiple classes into the same php file? What is the most effective way to handle classes and inclusion? How do you guys handle inclusions when working with classes dependent upon another in different directories?

And I don't really know what I mean with ::, all I know is that the source code to wordpress is filled with them x)