Home > php教程 > php手册 > body text

php抽象类用法实例分析,php抽象实例分析

WBOY
Release: 2016-06-13 08:58:32
Original
1597 people have browsed it

php抽象类用法实例分析,php抽象实例分析

本文实例讲述了php抽象类用法。分享给大家供大家参考。具体如下:

<&#63;php
/*
 * abstract
 * 抽象类:
 * 1、至少有一个抽象方法(没有具体实现的方法)
 * 2、不能被实例化,可以被继承
 * 3、抽象类可以有子抽象类
 * 相对于接口:
 * 1、可以有属性
 * 2、一个子类只能继承一个抽象类,但是可以实现多个接口
 * 
 * 
 * */
 abstract class qian {
  abstract function getfirst();
  function gettwo() {
    echo "I am gettwo";
  }
 }
 abstract class jj extends qian {
  abstract function getthree();
 }
 class nan extends jj {
  function getfirst() {
    echo "I am getfirst";
  }
  function getthree() {
    echo "I am getthree";
  }
 }
 $nn = new nan();
 $nn->getfirst();
 $nn->gettwo();
 $nn->getthree();
&#63;>

Copy after login

希望本文所述对大家的php程序设计有所帮助。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template