<?php
require_once __DIR__ . '/trait.Singleton.php';
require_once __DIR__ . '/class.Example.php';
$cat = Example::getSharedInstance('Cat', 'MEOW');
$brownCat = Example::getSharedInstance('Brown Cat', 'BREOW'); // Brown cat will sound same as $cat as its same instance
$dog = Example::getNewInstance('Dog', 'WOF');
$breakLine = php_sapi_name() === 'cli' ? "\n" : '<br>';
$cat->makeSound($breakLine);
$brownCat->makeSound($breakLine);
$dog->makeSound($breakLine);
|