mirror of
https://github.com/php/php-src.git
synced 2024-12-13 20:05:26 +08:00
315f4f5658
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.
59 lines
880 B
PHP
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
|