Home > Backend Development > PHP Tutorial > Example analysis PHP extends class inheritance_PHP tutorial

Example analysis PHP extends class inheritance_PHP tutorial

WBOY
Release: 2016-07-15 13:33:59
Original
850 people have browsed it

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类继承的全部实现步骤。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446027.htmlTechArticlePHP extends类继承代码示例: ?php classa{ public$x; public$y; function__construct($ x = 0 ,$ y = 0 ){ $this- x =$x; $this- y =$y; } functiongetx(){ return$this- x; } functio...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template