<?php class Car { private static $instance; private function __clone(){} private function __construct() {} public static function getInstance() { if ( self::$instance instanceof self ) { return self::$instance; } else { return self::$instance = new self(); } } public function getColor() { return 'red'; } } $car = Car::getInstance(); echo $car->getColor();