index.php
<?phpheader('Content-Type: text/html; charset=utf-8');require("Autoload.php");class test implements Singleton_Interface{public static function getInstance(){return new static;}}class test2{public static function getInstance(){return new static;}}$b=new test;if ($b instanceof Singleton_Interface) {echo get_class(test::getInstance());}
Autoload.php
<?phpif(!function_exists('__autoload')){function __autoload($sinifAdi){if(class_exists('Zend',false)){if(is_int(strrpos($sinifAdi,'_Interface'))){Zend::loadClass($sinifAdi);}else{Zend::loadInterface($sinifAdi);}}else{if(!defined('__CLASS_PATH__')){define('__CLASS_PATH__',realpath(dirname(__FILE__)));}$dosya=__CLASS_PATH__ . '/'.str_replace('_','/',$sinifAdi).'.php';if(!file_exists($dosya)){throw new Exception('Sınıf Dosyası Yüklenemiyor '.$sinifAdi);}else{require_once $dosya;}}}}
Singleton/Interface.php
<?phpif (!interface_exists('Singleton_Interface')) {interface Singleton_Interface{public static function getInstance();}}
Çıktısı
test