PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Aleksandar Zivanovic   SingletonTrait   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: SingletonTrait
Trait to implement the singleton design pattern
Author: By
Last change:
Date: 6 years ago
Size: 478 bytes


Class file image Download

require_once __DIR__ . '/trait.Singleton.php';
__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>';