How can the use of global constants like SERVER in class loading functions impact the maintainability of PHP code?

Using global constants like SERVER in class loading functions can make the code less maintainable because it introduces tight coupling between the class loading function and the specific server configuration. This can make it harder to reuse the code in different environments or make changes without affecting other parts of the code. To improve maintainability, it's better to avoid relying on global constants and instead pass any necessary configuration values as parameters to the function.

// Avoid using global constants like SERVER in class loading functions
function loadClass($className) {
    require_once(SERVER . '/path/to/classes/' . $className . '.php');
}

// Better approach: Pass server configuration as a parameter
function loadClass($className, $server) {
    require_once($server . '/path/to/classes/' . $className . '.php');
}

// Example usage
$server = 'localhost';
loadClass('ExampleClass', $server);