I have a file classes.php
in which I declare a set of classes to be used in a series of pages.
Then, in one page, I need to use another class, that is declared in a separate file. Now, this separate class uses some classes located in the classes.php
file.
So, in most pages, I have:
[1]
<?php
require('classes.php');
[page code]
?>
which works fine. The problem comes with that specific page, which has:
[2]
<?php
require('classes.php');
require('separate_class.php');
[page code]
?>
and this does not work because separate_class.php
also requires classes.php
.
If I try this:
[3]
<?php
require('separate_class.php');
[page code]
?>
then it does not work because now the classes are not available for this page, even if they are declared inside the separate_class.php
file.
The obvious solution seems to be the inclusion of the separate class in the classes.php
file, which is clumsy because this separate class makes sense only in this series of pages, while the file classes.php
contains general purpose classes and is shared among various applications.
How can I do it in a way that allows me to keep a structure like shown in [2], that is, separating general-purpose classes from a specific class which, in turn, requires those general-purpose classes, while still being able to use these general-purpose classes in the page?