復制代碼 代碼如下:
 
<?php 
class A { 
function example() { 
echo "I am the original function A::example().<br />/n"; 
} 
} 
class B extends A { 
function example() { 
echo "I am the redefined function B::example().<br />/n"; 
A::example(); 
} 
} 
// A 類沒有對象,這將輸出 
// I am the original function A::example().<br /> 
A::example(); 
// 建立一個 B 類的對象 
$b = new B; 
// 這將輸出 
// I am the redefined function B::example().<br /> 
// I am the original function A::example().<br /> 
$b->example(); 
?> 
新聞熱點
疑難解答