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 Jorge Prado  >  PHP Compare Objects  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: use example
Class: PHP Compare Objects
Compare objects using reflection
Author: By
Last change:
Date: 2013-04-08 12:57
Size: 1,082 bytes
 

Contents

Class file image Download
<?php
    
include('compareobject.php');
    class 
class1
    
{
        private 
$x;
        private 
$y;
        
        function 
__set($propiedad,$valor)
        {
            
$this->$propiedad=$valor;
        }
        function 
__get($propiedad)
        {
            return 
$this->$propiedad;
        }
    }
    
    
$object1=new class1();
    
$object1->x=10;
    
$object1->y=20;
    
    
$object2=new class1();
    
$object2->x=10;
    
$object2->y=20;
    
    
$object3=new class1();
    
$object3->x=10;
    
$object3->y=10;
    if(
compareobject::compareobjects($object1,$object2))
    {
        echo 
"The OBJECT 1: \n";
        
print_r($object1);
        echo 
"\nIs Equal to \n"//print 1
        
echo "The OBJECT 2: \n";
        
print_r($object2);
        echo 
"\n";
        echo 
"\n";
        echo 
"\n";
    }
    if(!
compareobject::compareobjects($object1,$object3))
    {
        echo 
"The OBJECT 1: \n";
        
print_r($object1);
        echo 
"\nIs not equal to \n"//print 1
        
echo "The OBJECT 3: \n";
        
print_r($object3);    
    }
    
?>