Home php教程 php手册 面向对象必看的9大重点

面向对象必看的9大重点

Jun 13, 2016 am 10:38 AM
one no shared big object encapsulation emphasize of program structure element For

一、面向对象的要素
1. 抽象性 , 2. 封装性 ,3.共享性 ,4. 强调对象结构而不是程序结构

面向对象的三大特点(封装,继承,多态)缺一不可

二、class MyPc{
public $name;   —>成员属性(可以理解为自定义变量)
var $price;
function vod() { —>成员方法(可以里金额为自定义函数)
return "bkJia视频教程";
   }
}
$pc1 = new MyPc();  —>实例化类
$pc1->name;         —>使用 -> 访问对象内容

三、OOp object Oriented Program 解释:程序向导开发

四、$this关键字是用来访问当前对象中的对象属性和对象方法的系统变量

五、析构函数 :能够在对象释放时自动被调用的方法被称为析构函数

六、封装关键字 :public,protected,private
    封装相关函数:__set() , __get()

七、public 表示全局,类内部外部子类都可以访问;
    protected表示受保护的,只有本类或子类或父类中可以访问;
    private表示私有的,只有本类内部可以使用;

八、继承关键字 :extends     单一继承

九、基类方法重载和父类方法访问   重载方法 基类名 :: 方法名称

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

How to make Google Maps the default map in iPhone

How to share wallpaperengine with friends How to share wallpaperengine with friends Mar 18, 2024 pm 10:00 PM

How to share wallpaperengine with friends

How to share screen on WeChat Enterprise How to share screen on WeChat Enterprise Feb 28, 2024 pm 12:43 PM

How to share screen on WeChat Enterprise

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Clock app missing in iPhone: How to fix it

Windows 11 Folder Sharing Guide: Easily Share Your Files and Data Windows 11 Folder Sharing Guide: Easily Share Your Files and Data Mar 13, 2024 am 11:49 AM

Windows 11 Folder Sharing Guide: Easily Share Your Files and Data

Can't allow access to camera and microphone in iPhone Can't allow access to camera and microphone in iPhone Apr 23, 2024 am 11:13 AM

Can't allow access to camera and microphone in iPhone

Shared printer cannot connect to printer Shared printer cannot connect to printer Feb 22, 2024 pm 01:09 PM

Shared printer cannot connect to printer

What is the Request object in PHP? What is the Request object in PHP? Feb 27, 2024 pm 09:06 PM

What is the Request object in PHP?

See all articles