Home >php教程 >php手册 >范例解析PHP extends类继承

范例解析PHP extends类继承

WBOY
WBOYOriginal
2016-06-13 11:10:531359browse

PHP extends类继承代码示例:

  1.  ?php  
  2. class a{  
  3. public $x;  
  4. public $y;  
  5. function __construct($x=0,$y=0){  
  6. $this->x=$x;  
  7. $this->y=$y;  
  8. }  
  9. function getx(){  
  10. return $this->x;  
  11. }  
  12. function gety(){  
  13. return $this->y;  
  14. }  
  15. function __destruct(){}  
  16. }  
  17. class a2 extends a{}   
    /*extends是一个继承函数*/  
  18. $b2=new a2(10,10);  
  19. echo $b2->getx()."br>";  
  20. echo $b2->gety();  
  21. ?> 

以上介绍的内容就是PHP extends类继承的全部实现步骤。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn