Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sourav ray  >  True Singleton Class  >  example.php  >  Download  
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
Author: By
Last change:
Date: 7 years ago
Size: 1,472 bytes
 

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>";
         
          
?>