PHP Classes

File: singleton.test.php

Recommend this page to a friend!
  Classes of Andrei Alexandru   Simple Singleton and Multiton Class   singleton.test.php   Download  
File: singleton.test.php
Role: Example script
Content type: text/plain
Description: Usage ot the singleton Class
Class: Simple Singleton and Multiton Class
Create and manage one or more singleton objects
Author: By
Last change: More examples
Date: 13 years ago
Size: 303 bytes
 

Contents

Class file image Download
<?php
// Requiere singleton class
require_once 'Singleton.class.php';

$single = Singleton::GetInstance();

// Fatal error -> private constructor
$newInstance = new Singleton();

// Fatal error -> No clonning
$clone = clone $single;

// Fatal error -> No serialization
serialize($single);