Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Simple abstract class with one
- * protected property
- */
- abstract class A
- {
- /**
- * An errors array property
- * @var array
- */
- protected $errors = array();
- }
- /**
- * Simple class which extends A
- */
- class B extends A
- {
- /**
- * An errors array property
- * @var array
- */
- protected $errors = array();
- /**
- * Value from constructor
- * @var string
- */
- protected $value = null;
- /**
- * Method stores value in property
- *
- * @access public
- * @param string $value Value to store
- * @return void
- */
- public function __construct($value)
- {
- $this->value = $value;
- }
- }
- // Creating new instance of B with "ABC" string
- $object1 = new B('ABC');
- // Creating new instance of B with "CBA" string
- $object2 = new B('CBA');
- // Both objects got different value of $value property
- // They should be different, but PHP returns true here
- var_dump($object1 == $object2);
- // Printing first object
- print_r($object1);
- // Printing second object
- print_r($object2);
- // Comparing objects again but now PHP returns false
- var_dump($object1 == $object2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement