The Singleton Pattern : Singleton Pattern « Design Patterns « PHP






The Singleton Pattern


<?php

class Preferences {
    private $props = array();

    private function __construct() { }

    public function setProperty( $key, $val ) { 
        $this->props[$key] = $val;
    }

    public function getProperty( $key ) { 
        return $this->props[$key];
    }
}

?>

           
       








Related examples in the same category

1.Singleton Pattern Demo