Blogger Information
Blog 250
fans 3
comment 0
visits 322914
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
OOP 面向对象 final 类的绝后修饰
梁凯达的博客
Original
734 people have browsed it

实例

<?php

	/*
		[修饰符]  class  类名{
			[成员属性]
			[成员方法]
		}

	 */
	// 关键字 final 最终的 
	// 关键字 可以修饰哪些内容 
	// 类   成员属性 还是成员方法

	//final  可以修饰类和方法
	// 被修饰的类不能被继承
	// 被修饰的方法不能被重写
	

	//绝后的类 final
	//final class A{
	class A{
		//final 不能修饰成员属性
		//final public $name;
		final public function say(){

		}
	}

	//被修饰的类不能被继承
	// class B extends A{}
	

	class C extends A{
		//被修饰的方法不能被重写
		public function say(){
			echo 1111;
		}
	}

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post