How can the Singleton Pattern be applied to address issues related to class instances and variable scope in PHP?

The Singleton Pattern can be applied to ensure that only one instance of a class is created and provide a global point of access to it, addressing issues related to multiple instances and variable scope in PHP.

class Singleton {
    private static $instance;

    private function __construct() {
        // private constructor to prevent instantiation
    }

    public static function getInstance() {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }
}

// Usage
$singletonInstance = Singleton::getInstance();