What are the differences in handling global instances and variables between PHP 4 and PHP 5, and how can developers adapt their code accordingly for better practices?

In PHP 4, global instances and variables were handled by simply declaring them as global within functions. In PHP 5, it is recommended to use the `$GLOBALS` superglobal array to access global variables and instances. Developers can adapt their code by updating all instances of global variables within functions to use the `$GLOBALS` array instead.

// PHP 4 style
$globalVar = 10;

function exampleFunction() {
    global $globalVar;
    echo $globalVar;
}

// PHP 5 style
$GLOBAL['globalVar'] = 10;

function exampleFunction() {
    echo $GLOBALS['globalVar'];
}