How can the issue of changing file paths for error report storage be addressed in PHP classes?

Issue: To address the problem of changing file paths for error report storage in PHP classes, we can use a configuration setting or a constructor parameter to specify the file path dynamically.

class ErrorLogger {
    private $filePath;

    public function __construct($filePath) {
        $this->filePath = $filePath;
    }

    public function logError($error) {
        file_put_contents($this->filePath, $error, FILE_APPEND);
    }
}

// Usage
$logger = new ErrorLogger('/path/to/error.log');
$logger->logError('An error occurred');