Q:

Php extends from different class runtime (extends as variable?)

This is going to be strange. I have a database class for MySQL, and independent classes. For example:
class users extends MySQL

this class is a general class for users, so that it can be used more times.
But occasionally, an "MySQL_DEBUGGED" class is present, and if so, I want to extend from it:
class users extends MySQL_DEBUGGED

I want to inherit MySQL_DEBUGGED if present, otherwise MySQL class. If I put it into variable, it drops an error. How to do it?

A:

I don't think you can inherit from a class which name is not written in the PHP script.

A possible solution would be :

to define two classes, both called MySQL, in two separate files
make your users class always extend the MySQL class (which means one of those two)
Depending on the situation, include :

the file that contains the "production" MySQL class, 
or the file that contains the "development" MySQL class

This way, your class always extends a MySQL class -- but you'll include the right one.

Basically, in your main file, you'd have :
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 would not contain the same stuff in both files, of course.

