I have a main class which is including two other scripts. They both are using a class with the same name which I can't change because it's a library. The two classes with the same name can also have a different Version. When I include the class a second time I get the error that I'm redeclaring the class LicenceManager
. My code:
/plugin-one/check_licence.php:
function plugin_one_isLicenceValid() {
...
require "/plugin-one/libs/class.licence_manager.php";
$licenceManager = new LicenceManager($path, $plugin_name);
return $licenceManager->isValid();
}
/plugin-two/check_licence.php:
function plugin_two_isLicenceValid() {
...
require "/plugin-two/libs/class.licence_manager.php";
$licenceManager = new LicenceManager($path, $plugin_name);
return $licenceManager->isValid();
}
main.php:
require '/plugins/plugin-one/check_licence.php';
$result = plugin_one_isLicenceValid();
...
require '/plugins/plugin-two/check_licence.php';
$result = plugin_two_isLicenceValid();
Is there a way to include the class a second time?
Why its not a duplicate?
Most existing questions seems to be able to edit the including class and add a namespace into it. I can't to that. I can only edit the two check_licence.php
files and the main.php