PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sourav ray  >  True Singleton Class  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: example of use of singleton class
Class: True Singleton Class
PHP implementation of the singleton design pattern
 

Contents

Class file image Download
<?php
     
include_once('singleton.class.php'); 
     
     echo 
"<br /><b>In this example we tried to create different instance of the sTonClass <br />
            But it every times returns the reference of the same instance . </b>"
;
     echo 
"<br />----------------------------------------------------------<br />";
        
$sTonClassObject1 =sTonClass::inisiate();
        
            
$rs=array("Dog","Cat","Horse");
            
$sTonClassObject1->put('a',$rs);
            
             echo 
"<pre>";
                
var_dump($sTonClassObject1);
             echo 
"</pre>";
        
    echo 
"----------------------------------------------------------<br />";
            
             
$sTonClassObject2 =sTonClass::inisiate(); 
             
$sTonClassObject2->put('b',71);
             
             echo 
"<pre>";
                
var_dump($sTonClassObject2);
             echo 
"</pre>";
             
             
$storedVariable1 $sTonClassObject2->get('a');
             echo 
"Using Get Method: <pre>";
                 
print_r($storedVariable1);
             echo 
"</pre>";
         
    echo 
"----------------------------------------------------------<br />";
             
$sTonClassObject3 =sTonClass::inisiate(); 
             
$sTonClassObject3->put('a',81);
              
$sTonClassObject3->put('c',900);
             echo 
"<pre>";
                
var_dump($sTonClassObject3);
             echo 
"</pre>";
    echo 
"----------------------------------------------------------<br />";
          
         
$sTonClassObject4 =sTonClass::inisiate(); 
         
$sTonClassObject4->invalidate('a');
         
$sTonClassObject4->put('a',500);
         echo 
"<pre>";
                
var_dump($sTonClassObject4);
         echo 
"</pre>";
         
          
?>


 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products