PHP Classes

File: example.php

Recommend this page to a friend!
  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: 11 years ago
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);
    }
   
?>