I know the difference between include
and require
. And I use require
in several places in my project.
But here is the thing: I want to include files ONCE and be able to call it's functions from other include files.
In my header.php file, I have the following code:
<?php
require_once('include/dal.php');
require_once('include/bll.php');
require_once('include/jquery_bll.php');
?>
Now, in my javascript, I'm calling the jquery_bll.php using jQuery.post, and in jquery_bll.php file I have the following code:
$myDB = new DAL();
My problem is that I get the error message "Class 'DAL' not found in (..)\jquery_bll.php".
I recon I get this message because the file is called from a javascript and therefore it outside of the "scope" or something...
So, is there anyway of including the needed files in header.php and not having to worry about including the same files again?