php-src/tests/classes/inheritance.phpt
Stig Bakken 315f4f5658 @PHP 3 regression testing framework re-born (Stig)
Took the old PHP 3 regression testing framework and rewrote it in PHP.
Should work on both Windows and UNIX, however I have not tested it on
Windows.  See tests/README for how to write tests.  Added the PHP 3
tests and converted most of them.
2000-08-27 19:46:06 +00:00

59 lines
880 B
PHP

--TEST--
Classes inheritance test
--POST--
--GET--
--FILE--
<?php
/* Inheritance test. Pretty nifty if I do say so myself! */
class foo {
var $a;
var $b;
cfunction display() {
echo "This is class foo\n";
echo "a = ".$this->a."\n";
echo "b = ".$this->b."\n";
}
cfunction mul() {
return $this->a*$this->b;
}
};
class bar extends foo {
var $c;
cfunction display() { /* alternative display function for class bar */
echo "This is class bar\n";
echo "a = ".$this->a."\n";
echo "b = ".$this->b."\n";
echo "c = ".$this->c."\n";
}
};
$foo1 = new foo;
$foo1->a = 2;
$foo1->b = 5;
$foo1->display();
echo $foo1->mul()."\n";
echo "-----\n";
$bar1 = new bar;
$bar1->a = 4;
$bar1->b = 3;
$bar1->c = 12;
$bar1->display();
echo $bar1->mul()."\n";
--EXPECT--
This is class foo
a = 2
b = 5
10
-----
This is class bar
a = 4
b = 3
c = 12
12