I do not think that you can inherit from a class whose name is not written in a PHP script.
Possible Solution:
- to define two classes called
MySQL in two separate files - so that your
users class always extends the MySQL class (which means one of these two) - Depending on the situation:
- a file containing the
MySQL "production" class, - or file containing the
MySQL class
Thus, your class always extends the MySQL class, but you enable it.
Basically, in your main file, you would:
if (DEBUG) { require __DIR__ . '/MySQL-debug.php'; } else { require __DIR__ . '/MySQL-production.php'; } class users extends MySQL {
And both MySQL-debug.php and MySQL-production.php will contain a class called MySQL , which, of course, will not contain the same material in both files.
source share