Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / tests / classes / inheritance.phpt
blob070ad9147d7c759da70c23a029f75ccb4dfa3c94
1 --TEST--
2 Classes inheritance test
3 --FILE--
4 <?php 
6 /* Inheritance test.  Pretty nifty if I do say so myself! */
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   }
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   }
32 $foo1 = new foo;
33 $foo1->a = 2;
34 $foo1->b = 5;
35 $foo1->display();
36 echo $foo1->mul()."\n";
38 echo "-----\n";
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
51 -----
52 This is class bar
53 a = 4
54 b = 3
55 c = 12