Annotation of embedaddon/php/tests/classes/inheritance.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Classes inheritance test
! 3: --FILE--
! 4: <?php
! 5:
! 6: /* Inheritance test. Pretty nifty if I do say so myself! */
! 7:
! 8: class foo {
! 9: public $a;
! 10: public $b;
! 11: function display() {
! 12: echo "This is class foo\n";
! 13: echo "a = ".$this->a."\n";
! 14: echo "b = ".$this->b."\n";
! 15: }
! 16: function mul() {
! 17: return $this->a*$this->b;
! 18: }
! 19: };
! 20:
! 21: class bar extends foo {
! 22: public $c;
! 23: function display() { /* alternative display function for class bar */
! 24: echo "This is class bar\n";
! 25: echo "a = ".$this->a."\n";
! 26: echo "b = ".$this->b."\n";
! 27: echo "c = ".$this->c."\n";
! 28: }
! 29: };
! 30:
! 31:
! 32: $foo1 = new foo;
! 33: $foo1->a = 2;
! 34: $foo1->b = 5;
! 35: $foo1->display();
! 36: echo $foo1->mul()."\n";
! 37:
! 38: echo "-----\n";
! 39:
! 40: $bar1 = new bar;
! 41: $bar1->a = 4;
! 42: $bar1->b = 3;
! 43: $bar1->c = 12;
! 44: $bar1->display();
! 45: echo $bar1->mul()."\n";
! 46: --EXPECT--
! 47: This is class foo
! 48: a = 2
! 49: b = 5
! 50: 10
! 51: -----
! 52: This is class bar
! 53: a = 4
! 54: b = 3
! 55: c = 12
! 56: 12
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>