How can inheritance be utilized to handle dynamic method calls in PHP, instead of directly accessing $_GET variables?

When handling dynamic method calls in PHP, inheritance can be utilized by creating a base class with a method that dynamically calls other methods based on the input. This can help avoid directly accessing $_GET variables and improve code organization and reusability.

class BaseClass {
    public function handleRequest($method, $params) {
        if (method_exists($this, $method)) {
            return $this->$method($params);
        } else {
            return "Method not found";
        }
    }
}

class ChildClass extends BaseClass {
    public function processInput($params) {
        // Process input parameters
        return "Processing input";
    }
}

// Example usage
$child = new ChildClass();
$method = $_GET['method'];
$params = $_GET['params'];

echo $child->handleRequest($method, $params);