What distinguishes a class as a Singleton in PHP?

A Singleton class in PHP is a class that can only have one instance at a time. This is achieved by making the constructor private and providing a static method to access the single instance. This ensures that no matter how many times the class is instantiated, only one instance is returned.

class Singleton {
    private static $instance;

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

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