<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> parent3.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head> <body>
<?php
class A {
public static $a="hello I am A<br>";
function example() {
echo "I am A::example()<br />";
echo self::$a;
}
} class B extends A {
function example() {
echo "I am B::example()<br />";
parent::example();
}
} $b = new B;
// 这将调用 B::example(),而它会去调用 A::example()。
$b->example();
echo '<hr>';
B::example();
?>
<hr><hr><hr>
<?php
class AA {
public static $a="hello I am AA<br>";
function example() {
echo "I am AA::example()<br />";
echo self::$a;
}
} class BB extends AA {
function example() {
echo "I am BB::example()<br />";
AA::example();
}
} $b = new BB;
// 这将调用 B::example(),而它会去调用 A::example()。
$b->example();
echo '<hr>';
BB::example();
?>
</body>
</html>
I am B::example()
I am A::example()
hello I am A
I am B::example()
I am A::example()
hello I am A
I am BB::example()
I am AA::example()
hello I am AA
I am BB::example()
I am AA::example()
hello I am AA