I've been through the site regarding this subject but I'm still confused. I have fixed my problem but I know deep down I have kind of cheated and it's a fix that could cause me problems further down the line. Let me explain where I am:
Here is a directory structure folders like this >> [folder name] :
/site root
[ajax-loads]
showorder.php
[bcls] << For bespoke classes
class.order.php
[cls] << For classes
class.main.php
class.db.php
class.sql.php
...
...
dashboard.php
index.php
config.php
...
.. etc etc
So above I'm showing I have 2 folders that contain classes for me to use of which most are called via an __autoload in class.main.php. The problem I am having is when I use jQuery to 'load()' new content in to a div; the behaviour changes and the path to the auto load is relative to the ajax-load file rather than relative to class.main.php. At the moment I have the following code where I feel I have cheated so to speak.
//PATHS & AUTOLOAD
set_include_path("./cls");
set_include_path("../cls");
set_include_path("./bcls");
set_include_path("../bcls");
//INVESTIGATE THIS NONESENSE ABOVE!
function __autoload($class_name)
{
require_once 'class' . '.' . $class_name . '.' . 'php';
}
Earlier in the file I am having the same issue with my config.php file which I have temp fixed with:
set_include_path("./");
set_include_path("../");
Now let me point out this is my first big project having decided to get away from procedural coding and this is my first real experience with autoload. Rather than be a copy paste coder I really need to understand this better; I have hit a gap in my understanding here I feel. As well as the code being corrected, would someone kindly explain what the correct code is doing as I have tried a few 'solutions' but I am still getting odd results after mimicking other people's examples.
Love and kisses Andy